Could not load type System.Runtime.Versioning.TargetFrameWorkAttribute from assembly

不想你离开。 提交于 2020-01-02 02:11:27

问题


I am trying to compile a program that uses the library Newtonsoft.Json.dll with mono

Compile command

gmcs Program.cs etcetera.cs -r:Newtonsoft.Json.dll -r:Argotic.Core.dll

Result:

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

And then when trying to run the program (mono Program.exe) it throws the error:

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 

I have never used mono before, and have no idea what's going on.. but maybe this means the DLL can't be used because it hasn't been compiled with mono as well? If that's the case; does this mean I can't use any 3d party DLLs with mono unless I also have the source code?


回答1:


Because default mono uses v 2.0 runtime but nuget is using v4.0. its can be resolve by defining runtime parameter on mono:

mono --runtime=v4.0.30319 NuGet.exe

Source: http://monomvc.wordpress.com/2012/03/06/nuget-on-mono/



来源:https://stackoverflow.com/questions/11600337/could-not-load-type-system-runtime-versioning-targetframeworkattribute-from-asse

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!