title: sgen TypeLoadException in Visual Studio for Mac when trying to build Xamarin.iOS app
body: <p>When compiling our app on MacOS in Visual Studio (version 7.0.1 build 24), I'm presented with the error:</p>
  
  <pre><code>/Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Error MSB6006: "sgen.exe" exited with code 1. (MSB6006) (SyncWebClientLight)
  </code></pre>
  
  <p>If I start a build in Visual Studio 2015 Pro (with VS2015 connecting to the Mac and compiling it there), then I can debug etc. This would be great, except that I can't generate an archive for submission into the App Store from VS2015 (for whatever reason, the "Archive" menu option is greyed out)</p>
  
  <p>Is there a way to disable sgen.exe in Visual Studio for Mac (some msbuild switch or something?) Might that help?</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>VS 2015 gives the following error: </p>
  
  <pre><code>Could not load file or assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)   SyncWebClientLight  C:\projects\mWORKSPACE\trunk\Source\SyncWebClientLight\SGEN
  </code></pre>
  
  <p>So that's a little more information, at least.</p>
  
  <p><strong>Update 2:</strong></p>
  
  <pre><code>Target GenerateSerializationAssemblies:
      /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/4.5/sgen.exe /assembly:/Users/mj/Documents/projects/mWORKSPACE/Source/SyncWebClientLight/obj/iPhoneSimulator/Release/SBW.SyncWebClientLight.dll /proxytypes /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/mscorlib.dll /reference:/Users/mj/Documents/projects/mWORKSPACE/Release/SBW.Sync.dll /reference:/Users/mj/Documents/projects/mWORKSPACE/Debug/SBW.SystemBase.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Core.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Data.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Web.Services.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Xml.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Xamarin.iOS.dll 
  
      Unhandled Exception:
      System.TypeLoadException: Could not load type of field 'SyncWebClientLight.ClientPackageController:_syncDef' (2) due to: Could not load file or assembly 'SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null type:&lt;unknown type&gt; member:&lt;none&gt;
        at (wrapper managed-to-native) System.RuntimeType:GetConstructors_native (System.RuntimeType,System.Reflection.BindingFlags)
        at System.RuntimeType.GetConstructors_internal (System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) [0x00008] in &lt;ffb99659fc1c47faa4d5f883014d08aa&gt;:0 
        at System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00034] in &lt;ffb99659fc1c47faa4d5f883014d08aa&gt;:0 
        at System.RuntimeType.GetConstructorImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in &lt;ffb99659fc1c47faa4d5f883014d08aa&gt;:0 
        at System.Type.GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00032] in &lt;ffb99659fc1c47faa4d5f883014d08aa&gt;:0 
        at System.Xml.Serialization.TypeScope.GetConstructorFlags (System.Type type, System.Exception&amp; exception) [0x00000] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.TypeScope.ImportTypeDesc (System.Type type, System.Reflection.MemberInfo memberInfo, System.Boolean directReference) [0x00444] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference, System.Boolean throwOnError) [0x00050] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference) [0x00000] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type, System.Boolean directReference) [0x00017] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type) [0x00000] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00014] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type) [0x00000] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at Driver.Run (System.String[] args) [0x00110] in &lt;eeaf85d64a8c4c2eb792db70e13a9f1e&gt;:0 
        at Driver.Main (System.String[] args) [0x00005] in &lt;eeaf85d64a8c4c2eb792db70e13a9f1e&gt;:0 
      [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'SyncWebClientLight.ClientPackageController:_syncDef' (2) due to: Could not load file or assembly 'SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null type:&lt;unknown type&gt; member:&lt;none&gt;
        at (wrapper managed-to-native) System.RuntimeType:GetConstructors_native (System.RuntimeType,System.Reflection.BindingFlags)
        at System.RuntimeType.GetConstructors_internal (System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) [0x00008] in &lt;ffb99659fc1c47faa4d5f883014d08aa&gt;:0 
        at System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00034] in &lt;ffb99659fc1c47faa4d5f883014d08aa&gt;:0 
        at System.RuntimeType.GetConstructorImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in &lt;ffb99659fc1c47faa4d5f883014d08aa&gt;:0 
        at System.Type.GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00032] in &lt;ffb99659fc1c47faa4d5f883014d08aa&gt;:0 
        at System.Xml.Serialization.TypeScope.GetConstructorFlags (System.Type type, System.Exception&amp; exception) [0x00000] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.TypeScope.ImportTypeDesc (System.Type type, System.Reflection.MemberInfo memberInfo, System.Boolean directReference) [0x00444] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference, System.Boolean throwOnError) [0x00050] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference) [0x00000] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type, System.Boolean directReference) [0x00017] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type) [0x00000] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00014] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type) [0x00000] in &lt;3a4ce9be61fd46ab845a4d68f2905e06&gt;:0 
        at Driver.Run (System.String[] args) [0x00110] in &lt;eeaf85d64a8c4c2eb792db70e13a9f1e&gt;:0 
        at Driver.Main (System.String[] args) [0x00005] in &lt;eeaf85d64a8c4c2eb792db70e13a9f1e&gt;:0 
      /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 "SyncWebClientLight.csproj" -- FAILED.
  </code></pre>
  
  <p>The Type is there though: I can drill down to its reference in VS4mac, the project SBW.Sync compiles fine, SyncWebClientLight is referencing the correct assembly.</p>
  
  <p>It would be nice if I knew where it was loading the assembly from (is there a fuslogvw.exe in mono?)</p>