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

标签 c# json mono

我正在尝试编译一个使用库 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

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

关于c# - 无法从程序集加载类型 System.Runtime.Versioning.TargetFrameWorkAttribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11600337/

相关文章:

c# - 如何在没有 BOM 的情况下使用 UTF8 而不是 UTF8 编写 XML?

c# - 从 EF 中的集合中删除项目 - 奇怪的问题

C#串口问题——太简单了,不过不行

c# - 使用 Mono Touch 的横向 iPad 应用程序

c# - 最大还是默认?

c# - 为什么在构建期间出现此错误?提到一些有关无法调试的信息

php - JSON 持久化/DOM

javascript - 如何在 React 中处理获取 API AJAX 响应

C# HttpClient 一个现有的连接被远程主机强行关闭

c# - Mono,asp.net C#和MVC的操作方法和教程