Json.NET不能在Debian下使用Mono [英] Json.NET doesn't work with Mono under Debian

查看:105
本文介绍了Json.NET不能在Debian下使用Mono的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#和Mono框架制作应用程序(以使其与Linux兼容)。



在这个应用程序中我也使用了Json。 NET库,但它似乎不适用于Mono,因为每次我尝试启动应用程序时都会收到此错误:



程序集中缺少方法.ctor root / igloo / Newtonsoft.Json.dll,类型System.Runtime.CompilerServices.ExtensionAttribute

找不到自定义attr构造函数图像:/root/igloo/Newtonsoft.Json.dll mtoken:0x0a000077

[20/03/14 06:11:50] System.UnhandledExceptionEventArgs

[错误]致命的未处理的异常:System.TypeLoadException:无法加载类型'System.Runtime.CompilerServices .ExtensionAttribute'来自程序集'Newtonsoft.Json'。

at Igloo.Core.Main(System.String [] args)[0x00000] in< filename unknown => :0



为什么会这样?我正在使用mono-complete(版本2.10)和Debian 7 64bit。

I'm making an application with C# and Mono framework (to make it compatible with Linux).

In this app I'm using also the Json.NET library, but it doesn't seem to work with Mono because every time I try to start the application I get this error:

Missing method .ctor in assembly /root/igloo/Newtonsoft.Json.dll, type System.Runtime.CompilerServices.ExtensionAttribute
Can't find custom attr constructor image: /root/igloo/Newtonsoft.Json.dll mtoken: 0x0a000077
[20/03/14 06:11:50] System.UnhandledExceptionEventArgs
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Newtonsoft.Json'.
at Igloo.Core.Main (System.String[] args) [0x00000] in <filename unknown=""> : 0

Why this happens? I'm using mono-complete (version 2.10) and Debian 7 64bit.

推荐答案

这里你可以找到关于这个类的一些信息。正如我所看到的,该类是在.Net 3.5中引入的,所以Mono可能不支持这些东西。只是为了让您知道:并非Mono支持.NET的所有功能。 Mono也可能不支持Json.NET。因此,我建议您检查您的Mono版本与适当版本的.NET框架的兼容性。此外,针对不同的.NET版本,有几种Json.NET版本。尝试与他们一起玩。此外, Qt框架是编写跨平台应用程序的更好选择。这不是太难学。
Here you can find some info about this class. As I can see, the class was introduced in the .Net 3.5, so this stuff may not be supported by Mono. Just for you to know: not every feature of .NET is supported by Mono. Json.NET is also may not be supported by Mono properly. So I'd suggest to check your Mono version compatibility with appropriate versions of .NET framework. Also, there are several builds of Json.NET for different .NET versions. Try to play with them. Also, Qt framework is a much better choice for writing crossplatform applications. It's not too hard to learn.


从错误中,听起来它找不到DLL。将DLL放在可执行文件旁边或运行命令:
From the error, it sounds like it cannot find the DLL. Place the DLL next to your executable or run the command:
sudo apt-get install Newtonsoft.Json

然后我认为运行时将知道要查找的位置。

and then I think the runtime will know where to look.


这篇关于Json.NET不能在Debian下使用Mono的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆