有人在大型或中型项目中使用过。net开源实现Mono吗?我想知道它是否已经为现实世界的生产环境做好了准备。它是否稳定、快速、兼容……足够用了吗?将项目移植到Mono运行时是否需要花费大量的精力,或者它是否真的足够兼容,只需要为微软的运行时编写代码就可以了?


当前回答

这里有几个场景需要考虑:(a)如果你正在移植一个现有的应用程序,并且想知道Mono是否足够好来完成这个任务;(b)你开始写一些新代码,你想知道Mono是否足够成熟。

对于第一种情况,您可以使用Mono迁移分析工具(Moma)来评估您的应用程序距离在Mono上运行还有多远。如果评估结果令人满意,你就应该开始测试和QA工作,并准备发布。

如果你的评估返回的报告强调了在Mono中缺失的功能或语义上的显著差异,你将不得不评估代码是否可以改编,重写,或者在最坏的情况下,你的应用程序是否可以在功能减少的情况下工作。

According to our Moma statistics based on user submissions (this is from memory) about 50% of the applications work out of the box, about 25% require about a week worth of work (refactoring, adapting) another 15% require a serious commitment to redo chunks of your code, and the rest is just not worth bothering porting since they are so incredibly tied to Win32. At that point, either you start from zero, or a business decision will drive the effort to make your code portable, but we are talking months worth of work (at least from the reports we have).

如果您从头开始,情况就简单多了,因为您将只使用Mono中存在的api。只要你继续使用支持的堆栈(基本上是。net 2.0,加上3.5的所有核心升级,包括LINQ和System)。核心,加上任何Mono跨平台api)你会很好。

每隔一段时间,你可能会在Mono中遇到bug或限制,你可能不得不解决它们,但这与其他系统没有什么不同。

至于可移植性:ASP。NET应用程序更容易移植,因为它们对Win32几乎没有依赖,你甚至可以使用SQL server或其他流行的数据库(Mono中有很多捆绑的数据库提供商)。

窗户表单移植有时比较棘手,因为开发人员喜欢逃离。net沙盒,用P/Invoke来配置一些有用的东西,比如用wParam中BCD格式编码的两个bezier点来表示改变光标闪烁速率。或者类似的垃圾。

其他回答

对于公认答案的建议现在有点过时了。

The windows forms implementation is pretty good now. (See Paint-Mono for a port of Paint.net which is a pretty involved Windows forms application. All that was required was an emulation layer for some of the P-Invoke and unsupported system calls). Path.Combine as well as Path.Seperator to join paths and filenames. The windows Registry is OK, as long as you are only using it for storing and retrieving data from your applications (i.e. you can't get any information about Windows from it, since it is basically a registry for Mono applications).

这实际上取决于您从. net框架中使用的名称空间和类。我有兴趣将我的一个windows服务转换到我的电子邮件服务器(Suse)上运行,但我们遇到了几个尚未完全实现的api的硬障碍。Mono网站上的某个地方有一个图表,列出了所有的课程及其完成程度。如果你的申请被覆盖了,那就去申请吧。

当然,像任何其他应用程序一样,在做出全面承诺之前要进行原型设计和测试。

我们遇到的另一个问题是授权软件:如果您引用的是别人的DLL,那么您就无法通过编写代码来绕过隐藏在该程序集中的不兼容性。

它覆盖了。net 4.0,甚至包括了。net 4.5 api的一些特性,但是有一些领域我们选择不去实现,因为api被弃用了,新的替代品被创建了,或者范围太大了。以下api在Mono中不可用:

Windows Presentation Foundation Windows Workflow Foundation(两个版本都不是) 实体框架 标准Web服务堆栈的WSE1/WSE2“附加组件”

此外,我们的WCF实现仅限于Silverlight支持的内容。

检查特定项目的最简单方法是运行Mono Migration Analyzer (MoMA)。好处是它会通知Mono团队那些会阻止你使用Mono的问题(如果有的话),这让他们优先考虑他们的工作。

我最近在SubSonic上运行了MoMA,只发现了一个问题——对Nullable类型的奇怪使用。这是一个很大的代码库,所以覆盖率非常高。

Mono在一些商业产品和开源产品中得到了积极的应用。它在一些大型应用程序中使用,如维基百科和Mozilla开发者中心,并已在嵌入式应用程序中使用,如Sansa MP3播放器,并为数以千计的已发行游戏提供了动力。

在语言层面,Mono编译器完全符合c# 5.0语言规范。

Yes it definitely is (if you're careful though) We support Mono in Ra-Ajax (Ajax library found at http://ra-ajax.org) and we're mostly not having problems at all. You need to be careful with some of the "most insane things" from .Net like WSE etc, and also probably quite some few of your existing projects will not be 100% Mono compatible, but new projects if you test them during development will mostly be compatible without problems with Mono. And the gain from supporting Linux etc through using Mono is really cool ;)

我认为支持Mono的很大一部分秘密是从一开始就使用正确的工具,例如ActiveRecord, log4net, ra-ajax等。

我个人在黄金时段使用Mono。 我运行单服务器处理千兆字节的udp/tcp数据处理相关任务,不能再高兴了。

有一些特殊之处,其中最烦人的事情之一是,由于Mono的当前状态,你不能“构建”你的msbuild文件:

MonoDevelop (the IDE) has some partial msbuild support, but will basically bork on any "REAL" build conf beyond a simple hello-world (custom build tasks, dynamic "properties" like $(SolutionDir), real configuration to name a few dead-ends) xbuild which SHOULD have been the mono-supplied-msbuild-fully-compatible-build-system is even more horrible, so building from the command line is actually a worse experience than using the GUI, which is a very "unorthodox" state of the union for Linux environments...

一旦/在你的东西真正构建的过程中,你可能会看到一些应该支持的代码的荒野:

编译器在某些构造上出错 一些更高级的/新的。net类向你抛出意想不到的垃圾(XLinq的人吗?) 一些不成熟的运行时“特性”(3GB堆限制在x64…WTF !)

但heaving表示,一般来说,事情很快就会开始起作用,而且解决方案/变通方法很多。

一旦你克服了这些最初的障碍,我的经验是,mono很摇滚,并在每次迭代中变得越来越好。

我有使用mono运行的服务器,每天处理300GB的数据,有大量的p/调用,通常来说要做大量的工作,并且保持5-6个月,即使使用“最先进的”mono。

希望这能有所帮助。