简体   繁体   English

使用Mono将C#.NET应用程序移植到OS X?

[英]Using Mono to port a C# .NET app to OS X?

Alrighty guys, I'm writing an application that I want to be cross-platform. 好吧,伙计们,我正在编写一个我想要跨平台的应用程序。 Up until recently I've been trying to do this in Silverlight with C# because it also runs on OS X, but with me being fairly rusty with C# in addition to being new to Silverlight I've run into headache after headache. 直到最近,我一直在尝试使用C#在Silverlight中执行此操作,因为它也可以在OS X上运行,但是除了对Silverlight不熟悉之外,我对C#相当生疏,但是在头痛之后我遇到了头痛。 Most of this stems from the restrictions that come along with an application that's intended to run in a browser, issues with it running differently when running from my development sever vs directly from a file://, etc. 其中大部分源于一个旨在在浏览器中运行的应用程序所带来的限制,当从我的开发服务器运行时直接从文件://等运行时,它的运行方式不同。

I'd rather completely abandon the whole OS X support idea than have to completely rewrite the app for OS X, especially since I have utterly NO experience writing for it. 我宁愿完全放弃整个OS X支持的想法,而不是完全重写OS X的应用程序,特别是因为我完全没有为它写的经验。 What I'm hoping to be able to do is write a regular app in C# .NET with Visual Studio for Windows and then easily port it to OS X with Mono. 我希望能够做的是使用Visual Studio for Windows在C#.NET中编写常规应用程序,然后使用Mono轻松将其移植到OS X.

How difficult is it to bring a .NET app over to OS X with Mono? 使用Mono将.NET应用程序带到OS X有多难? My app is fairly straightforward, there's nothing exotic going on with the forms or anything, so I'd have to assume that it'd be supported in Mono's WinForms implementation. 我的应用程序相当简单,表单或任何东西都没有任何异国情调,所以我不得不假设它在Mono的WinForms实现中得到支持。

Are there any good resources out there on how to port an app using Mono? 关于如何使用Mono移植应用程序有什么好的资源吗? Or, perhaps, am I missing the entire point and it simply lets you run .NET apps on OS X and I don't need to bother with porting? 或者,也许,我错过了整点,它只是让你在OS X上运行.NET应用程序,我不需要打扰移植?

Forgive my utter ignorance on the subject, I only started considering going this route like 10 minutes ago after running into yet another annoying restriction in Silverlight. 原谅我对这个问题一无所知,我只是在10分钟前开始考虑在Silverlight中遇到另一个烦人的限制之后走这条路。

I'll be the first to admit that I don't know my head from my ass about this subject, so be gentle.. :) 我将是第一个承认我不知道我的屁股关于这个主题的人,所以要温柔...... :)

Appart from MoMa as mentioned in the other answers you might be interested in MonoMac. 您可能对MonoMac感兴趣的其他答案中提到的MoMa公寓。 With the success of MonoTouch (writing c# for iPhone), there is now also a project called MonoMac to create native UI's for OSX while using .net/mono in the background. 随着MonoTouch的成功(为iPhone编写c#),现在还有一个名为MonoMac的项目,用于在后台使用.net / mono时为OSX创建本机UI。 Might be interesting for you http://www.mono-project.com/MonoMac , article on Miguel de Icaza's blog: http://tirania.org/blog/archive/2010/Apr-19.html 您可能会对此感兴趣http://www.mono-project.com/MonoMac ,关于Miguel de Icaza博客的文章: http//tirania.org/blog/archive/2010/Apr-19.html

In addition to what has been said already, considering that Mono supports a subset of the full .NET functionality, I would probably prefer to develop on Mono, then test against Microsoft's runtime, if the aim is to run on both of those. 除了已经说过的内容,考虑到Mono支持完整.NET功能的一个子集,我可能更喜欢在Mono上开发,然后针对Microsoft的运行时进行测试,如果目标是在这两者上运行。 Otherwise, you run the risk of inadvertantly using some functionality that isn't available in Mono, and have to throw a large chunk of code out the window by the time you get around to doing the cross-platform build and testing. 否则,您将面临无意中使用Mono中无法使用的某些功能的风险,并且在您进行跨平台构建和测试时必须从窗口中抛出大量代码。

There are several things you should keep in mind. 你应该记住几件事。

  1. you'll have to port any usage of platform depedendent UI code 你将不得不移植平台unpdendent UI代码的任何使用
  2. don't use platform dependentent OS calls (win32 api) 不要使用平台相关的OS调用(win32 api)
  3. don't use "exotic" libraries (like workflow, sadly ef) 不要使用“异国情调”的图书馆(如工作流程,遗憾的是ef)
  4. In general: abstract dependencies to such code away, so you can easily replace them with mono-specific libraries. 通常:抽象依赖于此类代码,因此您可以轻松地将它们替换为特定于单一的库。 (an adviseable pattern would be MVVM). (一个可行的模式是MVVM)。

There is a tool called MoMA that will help you with all that. 有一个名为MoMA的工具可以帮助您完成所有这些工作。 However, take the results with a grain of salt. 但是,用一粒盐取结果。 In any case, just try it. 无论如何,试试吧。

Mono project has a page dedicated to how to port applications, Mono项目有一个专门介绍如何移植应用程序的页面,

http://mono-project.com/Guidelines:Application_Portability http://mono-project.com/Guidelines:Application_Portability

However, it is never enough as your application can be unique in so many ways. 但是,它永远不够,因为您的应用程序在很多方面都是独一无二的。

Try to port it and report issues to Mono guys whenever necessary. 尝试移植它并在必要时向Mono人报告问题。 Besides, if you work for a firm, consider Mono's commercial support service, 此外,如果您在公司工作,请考虑Mono的商业支持服务,

http://mono-project.com/Support http://mono-project.com/Support

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

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