我正在尝试编译一个使用库 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 不能使用,因为它也没有用单声道编译?如果是这样的话;这是否意味着我不能将任何 3d 派对 DLL 与单声道一起使用,除非我也有源代码?
最佳答案
因为默认单声道使用 v 2.0 运行时,但 nuget 使用 v4.0。它可以通过在单声道上定义运行时参数来解决:
mono --runtime=v4.0.30319 NuGet.exe
关于c# - 无法从程序集加载类型 System.Runtime.Versioning.TargetFrameWorkAttribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11600337/