简体   繁体   English

使用Mono运行.NET 4应用程序

[英]Running .NET 4 application with Mono

I'm trying to run a .NET exe on a Ubuntu machine (I installed the package mono-complete ), so far with no luck. 我试图在Ubuntu机器上运行.NET exe(我安装了mono-complete软件包),到目前为止没有任何运气。 The application is compiled with Visual C# Express 2010 under .NET 4 (Client Profile). 该应用程序使用.NET 4(客户端配置文件)下的Visual C#Express 2010进行编译。

I try executing the program with the following command: 我尝试使用以下命令执行程序:

mono application.exe

However, I get the following error: 但是,出现以下错误:

WARNING: The runtime version supported by this application is unavailable. 警告:此应用程序支持的运行时版本不可用。 Using default runtime: v1.1.4322 使用默认运行时:v1.1.4322

** (application.exe:5586): WARNING **: Missing method System.Windows.Forms.Application::SetCompatibleTextRenderingDefault(bool) in assembly /usr/lib/mono/gac/System.Windows.Forms/1.0.5000.0__b77a5c561934e089/System.Windows.Forms.dll, referenced in assembly /media/disk/application.exe **(application.exe:5586):警告**:程序集/usr/lib/mono/gac/System.Windows.Forms/1.0.5000.0__b77a5c561934e089中缺少System.Windows.Forms.Application :: SetCompatibleTextRenderingDefault(bool)方法/System.Windows.Forms.dll,在程序集/media/disk/application.exe中引用

Unhandled Exception: System.MissingMethodException: Method not found: 'System.Windows.Forms.Application.SetCompatibleTextRenderingDefault'. 未处理的异常:System.MissingMethodException:找不到方法:'System.Windows.Forms.Application.SetCompatibleTextRenderingDefault'。

It's suppose to be using .NET 4, not 1, but I don't know how to set it. 假定正在使用.NET 4,而不是1,但我不知道如何设置它。 I tried 我试过了

mono --runtime=4.0.30319.1 application.exe

But that didn't work either. 但这也不起作用。

Any help would be appreciated. 任何帮助,将不胜感激。

Sounds like you're experiencing this bug: 听起来您遇到了此错误:

My Doc's Got No Nodes: .net 4 Client Profile on Mono 2.8 我的文档没有节点:Mono 2.8上的.net 4客户端配置文件

That is assuming you installed > Mono 2.8 (which was the first release to support .NET 4.0). 假设您已安装> Mono 2.8(这是第一个支持.NET 4.0的版本)。 If not, you should install a more recent Mono package. 如果没有,则应安装更新的Mono软件包。

The other thing to keep in mind is that Mono doesn't support the entirety of WinForms. 要记住的另一件事是,Mono不支持整个WinForms。 Unless you developed your application with Mono in mind, there's a good chance you'll find that something you used isn't supported. 除非您在开发应用程序时就牢记Mono,否则很有可能会发现您所使用的内容不受支持。

I suspect the exception is because the method System.Windows.Forms.Application.SetCompatibleTextRenderingDefault hasn't been implemented. 我怀疑异常是因为尚未实现System.Windows.Forms.Application.SetCompatibleTextRenderingDefault方法。 Have you ran the tool through the Mono Migration Analyzer (MoMA) , should help in knowing whether your application is compatible with mono. 您是否已通过Mono迁移分析器(MoMA)运行了该工具,应该有助于了解您的应用程序是否与Mono兼容。 From that point you can possibly workaround the problem, maybe even incorporating the missing method in your code. 从那时起,您可以解决该问题,甚至可以在代码中合并缺少的方法。

Current mono-complete package (even on Ubuntu Natty) uses mono 2.6.7 which doesn't support .NET 4.0 API. 当前的单声道完整软件包(甚至在Ubuntu Natty上)使用的单声道2.6.7不支持.NET 4.0 API。 You'll have to build newest version of mono, which is the best way to get a chance of using 4.0 API. 您将必须构建最新版本的mono,这是获得使用4.0 API的最佳途径。 " Complete " support of .NET 4.0 is however planned in mono 3.0. 但是,在mono 3.0中计划了对.NET 4.0的“ 完全 ”支持。

安装Monodevelop,然后右键单击example.csprj(这是Linux中的C#.NET项目),然后单击Monodevelop。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM