Windows 上的 Mono 有什么意义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/751648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:18:38  来源:igfitidea点击:

What's the point of Mono on Windows

windowsmono

提问by Adam Haile

This may be a dumb question...but I was just looking into the Mono project and they have a section about installing Mono on Windows. But, since Windows obviously already has the .NET runtime can anyone tell me what exactly is the point of having Mono for Windows? Does it help with cross platform development or something?

这可能是一个愚蠢的问题......但我只是在研究 Mono 项目,他们有一个关于在 Windows 上安装Mono的部分。但是,由于 Windows 显然已经拥有 .NET 运行时,谁能告诉我拥有 Mono for Windows 的真正意义是什么?它对跨平台开发有帮助吗?

回答by J?rg W Mittag

There are a couple of features Mono has that .NET doesn't.

Mono 有一些 .NET 没有的功能。

Mono is highly modular. You can break it apart in tiny little pieces and only deploy exactlythose parts that you need. Don't want System.Xml? Fine, it's gone.

Mono 是高度模块化的。您可以在微小的碎片分解并仅部署完全相同的部分,你需要。不想要 System.Xml?好了,没了。

Mono is embeddable. You can host it inside your C/C++ application, to allow users to script it from a safe managed sandboxed environment. The most famous example of this is mod_mono, which hosts Mono inside the Apache webserver, and is how ASP.NET is implemented in Mono, for example. This feature goes great together with the modularization mentioned above.

Mono 是可嵌入的。您可以将其托管在您的 C/C++ 应用程序中,以允许用户从安全的托管沙盒环境中编写脚本。最著名的例子是 mod_mono,它在 Apache 网络服务器中托管 Mono,例如 ASP.NET 是如何在 Mono 中实现的。这个特性与上面提到的模块化非常相配。

This has already been mentioned: static linking. Alsogoes great together with modularization.

这已经提到过:静态链接。与模块化很相配。

Compiler as a Service is another one. Anders Hejlsberg has been talking about it for a longtime, and maybe, just maybe it is going to be ready for C# 5.0. Well, Mono already has it, and actually had it for years.

编译器即服务是另一个。Anders Hejlsberg 已经讨论了长时间,也许,只是也许它会为 C# 5.0 做好准备。嗯,Mono 已经拥有它,而且实际上已经拥有它多年了。

Miguel de Icaza, Mono's Lead Developer also has an initiative that he calls "Embrace and Extend.NET", which extends the CLI in ways not (currently) possible with other CLI implementations (including .NET). So far, Embrace and Extend.NET has three features.

Mono 的首席开发人员 Miguel de Icaza 还发起了一项他称之为“拥抱和扩展.NET”的计划,该计划以其他 CLI 实现(包括 .NET)(目前)无法实现的方式扩展 CLI。到目前为止,Embrace 和 Extend.NET 具有三个特性。

Mono.Simd, which gives safe and controlled access to the SIMD instructions of the underlying CPU (e.g. SSE on Intel or AltiVec on PowerPC). Used for Games and Graphics.

Mono.Simd,它提供对底层 CPU(例如 Intel 上的 SSE 或 PowerPC 上的 AltiVec)的 SIMD 指令的安全和受控访问。用于游戏和图形。

64 Bit array indices, which are allowed by the ECMA specification, but Mono is the only VM that actually provides them. Used in supercomputing.

ECMA 规范允许的 64 位数组索引,但 Mono 是唯一实际提供它们的 VM。用于超级计算。

And most recently, continuations. This is actually the first time that Mono strays outside the realm of the specification: long array indices are perfectly valid as per the spec, and Mono.Simd also works on every CLI compliant implementation (albeit veryS-L-O-W), but Mono.Tasklet needs special support from the VM that is not part of either CLI or .NET. This is used for game logic and e.g. in Second Life.

最近,延续。这实际上是 Mono 第一次偏离规范范围:根据规范,长数组索引完全有效,Mono.Simd 也适用于每个 CLI 兼容的实现(尽管非常慢),但 Mono.Tasklet 需要特殊的来自不属于 CLI 或 .NET 的 VM 的支持。这用于游戏逻辑,例如在第二人生中。

回答by Kibbee

Because Mono Doesn't implement .Net 100% the same as the MS .Net Framework, it's good that you can test out on Mono without having to run on Linux. Also Mono has bindings to make forms with GTK which MS doesn't support.

因为 Mono 不像 MS .Net Framework 那样实现 .Net 100%,所以您可以在 Mono 上进行测试,而不必在 Linux 上运行,这很好。Mono 还具有使用 MS 不支持的 GTK 制作表单的绑定。

回答by Joel Coehoorn

Mono does some things the .Net doesn't.

Mono 做了一些 .Net 没有的事情。

For example, mono supports static linking so you can build, compile, and distribute your app without requiring a separate run-time installer. If you built an app to rely on mono to be cross-platform, there are some differences from .Net and so sticking with mono on Windows is a greater guarantee of compatibility.

例如,mono 支持静态链接,因此您可以构建、编译和分发您的应用程序,而无需单独的运行时安装程序。如果您构建的应用程序依赖于单声道跨平台,则与 .Net 存在一些差异,因此在 Windows 上坚持使用单声道可以更好地保证兼容性。

.Net does some things that mono doesn't.

.Net 做了一些单声道没有的事情。

There are a few places in the BCL that are not yet ported for mono, such as WPF and Winforms, among others.

BCL 中有一些地方还没有移植到单声道,例如 WPF 和 Winforms 等。

If you want an app that will also work on mac/linux you probably want to develop for mono first, even if you're doing the most of the work on windows.

如果你想要一个也能在 mac/linux 上运行的应用程序,你可能想先为单声道开发,即使你在 windows 上做大部分工作。



Note:all of this pre-dates .Net Core/Standard.

注意:所有这些都早于 .Net Core/Standard。

回答by Ohad Schneider

From Mono's technical FAQ:

来自 Mono 的技术常见问题解答

Why support Windows, when you can run the real thing?

There are various reasons:

Supporting Windows helps us identify the portable portions of Mono from the non-portable versions of it, helping Mono become more portable in the future.

It assists us since we can isolate problems in Mono by partitioning the problem (is it a runtime issue, or an OS issue?).

About half the contributors to Mono are Windows developers. They have many different reasons for contributing to the effort, and we find it very important to let those developers run the runtime on Windows without forcing them to use a new operating system.

Mono does not heavily modify the windows registry, update system DLLs, install DLLs to the Windows/System32 path.

It helps Windows-based developers to test their code under Mono before they deploy into Linux.

Mono and applications that embed Mono can be deployed without an installer (you can "xcopy" deploy your application and the required Mono files without installing the .NET runtime).

为什么支持Windows,什么时候可以运行真正的东西?

有多种原因:

支持 Windows 有助于我们从 Mono 的非便携版本中识别出 Mono 的便携部分,从而帮助 Mono 在未来变得更加便携。

它对我们有帮助,因为我们可以通过划分问题来隔离 Mono 中的问题(它是运行时问题还是操作系统问题?)。

Mono 大约一半的贡献者是 Windows 开发人员。他们有很多不同的原因来为这项工作做出贡献,我们发现让这些开发人员在 Windows 上运行运行时而不强迫他们使用新的操作系统非常重要。

Mono 不会大量修改 Windows 注册表、更新系统 DLL、将 DLL 安装到 Windows/System32 路径。

它帮助基于 Windows 的开发人员在部署到 Linux 之前在 Mono 下测试他们的代码。

Mono 和嵌入 Mono 的应用程序无需安装程序即可部署(您可以“xcopy”部署您的应用程序和所需的 Mono 文件,而无需安装 .NET 运行时)。

回答by Joachim Sauer

If you want to develop a cross-platform application in C#, then using Microsoft's implementation is not the smartest thing, as there is no fully compatible alternative for other platforms.

如果你想用 C# 开发一个跨平台的应用程序,那么使用微软的实现并不是最聪明的事情,因为其他平台没有完全兼容的替代方案。

So using Mono on Windows to develop applications ensures that you'll have little trouble porting it to other OS (provided you avoid other pits such as P/Invoke).

所以在 Windows 上使用 Mono 开发应用程序可以确保你将其移植到其他 OS 上不会有什么麻烦(前提是你避免了 P/Invoke 等其他坑)。

回答by jpobst

Some people have used it because they are not allowed to install the .Net framework on their Windows PC's, due to the amount of registry and system files mucking it does. (In tightly controlled environments.)

有些人使用它是因为他们不允许在他们的 Windows PC 上安装 .Net 框架,因为它有大量的注册表和系统文件。(在严格控制的环境中。)

Mono, on the other hand, is self contained in Program Files, and only writes a registry key with a path it in (which isn't necessary to run).

另一方面,Mono 是自包含在 Program Files 中的,并且只写入一个带有路径的注册表项(这不是运行所必需的)。

I think this is kinda silly, but it is something that multiple users have told us.

我认为这有点愚蠢,但这是多个用户告诉我们的。

回答by Nick Berardi

It is mostly there as an aid to developing Mono apps for the Mono specific libraries. Also for helping to advance the cause, so that developers can work in their natural environment when developing for Mono.

它主要用于帮助为 Mono 特定库开发 Mono 应用程序。也为了帮助推进事业,让开发人员在为 Mono 开发时可以在他们的自然环境中工作。

回答by Erv Walter

While not of widespread interest, there are a few cases where mono has improvements over the standard Microsoft runtime. Migel gave a talk on some of these at PDC this year:

虽然没有引起广泛关注,但在少数情况下,mono 对标准 Microsoft 运行时进行了改进。Migel 今年在 PDC 上就其中一些内容发表了演讲:

See these posts:

看到这些帖子:

回答by user451234

also even if you have program dynamically linked with Mono, you can have that compiled .exe and Mono runtime on pendrive and goto another computer with no .NET/Mono installed, and run that program on the new PC without any runtime installation. ie, It leads to portable apps (particularly useful as portable usb pen drive apps) This is not possible with .NET. You have to have .NET runtime installed in a particular installer way,ie, runtime containing folder copy and paste not possible.

此外,即使您的程序与 Mono 动态链接,您也可以在 pendrive 上编译 .exe 和 Mono 运行时,然后转到另一台未安装 .NET/Mono 的计算机,然后在新 PC 上运行该程序,而无需安装任何运行时。即,它导致便携式应用程序(特别是用作便携式 USB 笔式驱动器应用程序)这在 .NET 中是不可能的。您必须以特定的安装程序方式安装 .NET 运行时,即无法复制和粘贴包含文件夹的运行时。

回答by Zifre

I think the main reason they did this is so they can run .NET applications on Mono and .NET side-by-side to compare them. Also, there are a few applications that depend on Mono libraries.

我认为他们这样做的主要原因是他们可以在 Mono 和 .NET 上并排运行 .NET 应用程序来比较它们。此外,还有一些应用程序依赖于 Mono 库。