无法从程序集加载类型System.Runtime.Versioning.TargetFrameWorkAttribute

nat*_*tli 8 c# mono json

我正在尝试编译一个使用Newtonsoft.Json.dll单声道库的程序

编译命令

gmcs Program.cs etcetera.cs -r:Newtonsoft.Json.dll -r:Argotic.Core.dll
Run Code Online (Sandbox Code Playgroud)

结果:

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
Run Code Online (Sandbox Code Playgroud)

然后当尝试运行程序(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 
Run Code Online (Sandbox Code Playgroud)

我之前从未使用过mono,也不知道发生了什么......但也许这意味着DLL无法使用,因为它还没有使用单声道编译?如果是这样的话; 这是否意味着我不能使用单声道的任何3D派对DLL,除非我也有源代码?

Tar*_*rik 6

因为默认单声道使用v 2.0运行时但nuget正在使用v4.0.它可以通过在mono上定义运行时参数来解决:

mono --runtime=v4.0.30319 NuGet.exe
Run Code Online (Sandbox Code Playgroud)

资料来源:http://monomvc.wordpress.com/2012/03/06/nuget-on-mono/