我正在尝试编译一个使用库Newtonsoft.Json.dll和mono的程序
编译命令
gmcs Program.cs etcetera.cs -r:Newtonsoft.Json.dll -r:Argotic.Core.dll结果:
Missing method .ctor in assembly Newtonsoft.Json.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
Can't find custom attr constructor image: Newtonsoft.Json.dll mtoken: 0x0a000053然后,当尝试运行程序(mono Program.exe)时,它抛出错误:
Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'Newtonsoft.Json'.
at my_program.CJSONStuff.serialize (System.Collections.Generic.Dictionary`2 obj) [0x00000] in <filename unknown>:0
at my_program.TheObjDB.getAllSerialized () [0x00000] in <filename unknown>:0
at my_program.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'Newtonsoft.Json'.
at my_program.CJSONStuff.serialize (System.Collections.Generic.Dictionary`2 obj) [0x00000] in <filename unknown>:0
at my_program.TheObjDB.getAllSerialized () [0x00000] in <filename unknown>:0
at my_program.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 我以前从来没有用过单声道,也不知道发生了什么。但这可能意味着DLL不能使用,因为它还没有用mono编译?如果是这样的话,这是不是意味着我不能在mono中使用任何3d party DLL,除非我还有源代码?
发布于 2012-07-22 20:38:30
因为默认的mono使用v2.0运行时,而nuget使用v4.0。它可以通过在mono上定义运行时参数来解决:
mono --runtime=v4.0.30319 NuGet.exe来源:http://monomvc.wordpress.com/2012/03/06/nuget-on-mono/
https://stackoverflow.com/questions/11600337
复制相似问题