首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法从程序集加载类型System.Runtime.Versioning.TargetFrameWorkAttribute

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

Stack Overflow用户
提问于 2012-07-22 20:33:34
回答 1查看 8.8K关注 0票数 8

我正在尝试编译一个使用库Newtonsoft.Json.dll和mono的程序

编译命令

代码语言:javascript
复制
gmcs Program.cs etcetera.cs -r:Newtonsoft.Json.dll -r:Argotic.Core.dll

结果:

代码语言:javascript
复制
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)时,它抛出错误:

代码语言:javascript
复制
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不能使用,因为它还没有用mono编译?如果是这样的话,这是不是意味着我不能在mono中使用任何3d party DLL,除非我还有源代码?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-07-22 20:38:30

因为默认的mono使用v2.0运行时,而nuget使用v4.0。它可以通过在mono上定义运行时参数来解决:

代码语言:javascript
复制
mono --runtime=v4.0.30319 NuGet.exe

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

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11600337

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档