我正在尝试使用mono编译一个使用Newtonsoft.Json.dll
库的程序。
编译命令:
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
我以前从未使用过mono,也不知道发生了什么...但也许这意味着DLL不能被使用,因为它还没有与mono一起编译?如果是这种情况,这是否意味着我除非也有源代码,否则无法在mono中使用任何第三方DLL?
apt-get install mono-complete
安装了版本为2.6.7,而我需要至少2.8才能运行 .net 4.0... 看来我得从源代码安装2.10.. 唉。还是谢谢你! - natlimono
的 man 页面,只有在尝试在不同于目标运行时的运行时上运行程序集时才需要这样做,也许它只是回退到了你所拥有的内容。 - markmnl