Error MSB6006: “sgen.exe” exited with code 1. (MSB6006)
In one of my Xamarin Forms (using Visual Studio for Mac) project I’ve found the following error message when I try to deploy it on my iPhone for testing:
Error MSB6006: “sgen.exe” exited with code 1. (MSB6006)
Even though the Build output contains some more data, I did not find any clue how to fix it:
Unhandled Exception:
System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes ()
at Driver.Run (System.String[] args)
at Driver.Main (System.String[] args)
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes ()
at Driver.Run (System.String[] args)
at Driver.Main (System.String[] args)
/Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(3366,5): error MSB6006: “sgen.exe” exited with code 1.
Done building target “GenerateSerializationAssemblies” in project “MyApp.iOS.csproj” — FAILED.
Target _CleanRecordFileWrites:
MakeDir Task
Directories:
obj/iPhone/Release/Done building project “MyApp.iOS.csproj” — FAILED.
Build FAILED.
Postings in Xamarin Forum recommend to check the versions, but that did not help for me.
Fortunaly there is still Xamarin Studio for Mac available. So I opened my project from there and tried to deploy it to my iPhone. It still fails, but I get a much better error message:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: Error: No installed provisioning profiles match the installed iOS signing identities.
And that’s true.
After fixing that, I was able to deploy the iOS app to my iPhone using Xamarin Studio.
If that does not help, maybe check whether your target device is included in your certificate:
ApplicationVerificationFailed: Failed to verify code signature of …/MyApp.iOS.app : 0xe8008015 (A valid provisioning profile for this executable was not found.)
error MT1006: Could not install the application ‘/iPhone/Release/MyApp.iOS.app’ on the device ‘iPhone’: Your application failed code-signing checks. Check your certificates, provisioning profiles, and bundle ids. Probably your device is not part of the selected provisioning profile (error: 0xe8008015).