在Visual Studio(版本7.0.1 build 24)的MacOS上编译我们的应用程序时,出现以下错误:
/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)
如果我在Visual Studio 2015 Pro中启动构建(通过VS2015连接到Mac并在其中进行编译),则可以调试等。这很棒,除了我无法生成存档以从以下位置提交到App Store中: VS2015(无论出于何种原因,“存档”菜单选项均显示为灰色)
有没有一种方法可以在Mac的Visual Studio中禁用sgen.exe(某些msbuild开关或其他功能?)有帮助吗?
更新1:
VS 2015出现以下错误:
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
至少这是更多信息。
更新2:
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:<unknown type> member:<none>
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 <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00034] in <ffb99659fc1c47faa4d5f883014d08aa>: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 <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Type.GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00032] in <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Xml.Serialization.TypeScope.GetConstructorFlags (System.Type type, System.Exception& exception) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.TypeScope.ImportTypeDesc (System.Type type, System.Reflection.MemberInfo memberInfo, System.Boolean directReference) [0x00444] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference, System.Boolean throwOnError) [0x00050] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type, System.Boolean directReference) [0x00017] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00014] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at Driver.Run (System.String[] args) [0x00110] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
at Driver.Main (System.String[] args) [0x00005] in <eeaf85d64a8c4c2eb792db70e13a9f1e>: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:<unknown type> member:<none>
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 <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00034] in <ffb99659fc1c47faa4d5f883014d08aa>: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 <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Type.GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00032] in <ffb99659fc1c47faa4d5f883014d08aa>:0
at System.Xml.Serialization.TypeScope.GetConstructorFlags (System.Type type, System.Exception& exception) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.TypeScope.ImportTypeDesc (System.Type type, System.Reflection.MemberInfo memberInfo, System.Boolean directReference) [0x00444] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference, System.Boolean throwOnError) [0x00050] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type, System.Boolean directReference) [0x00017] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00014] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
at Driver.Run (System.String[] args) [0x00110] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
at Driver.Main (System.String[] args) [0x00005] in <eeaf85d64a8c4c2eb792db70e13a9f1e>: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.
但是类型是存在的:我可以在VS4mac,SBW.Sync项目中深入查看其引用,SyncWebClientLight可以引用正确的程序集。
如果我知道它从哪里加载程序集,那将是很好的(mono中是否有fuslogvw.exe?)
最佳答案
因此,似乎Visual Studio for Mac无法理解csproj / msbuild标志:
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
而sgen不会让我继续工作。因此,让我们用不执行任何操作的自己的版本替换sgen!
sgen在我的Mac上位于:
/Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/4.5
我在VS4mac中制作了一个简单的.NET控制台应用程序,该应用程序什么也不做,然后将其复制到该目录中,以替换原始的sgen.exe。
现在,我可以编译我的程序集,由于担心我做了一些我不应该做的事情,所以只产生了些许幸福感。
如果有人知道如何正确解决此问题,我将非常有义务。