Linux下如何运行C#项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/950360/
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-08-06 04:03:25  来源:igfitidea点击:

How to run C# project under Linux

c#.netlinux

提问by user101375

Do you know any ways to run a C# project under Linux. Are there any framewoks or libraries for this?

你知道在Linux下运行C#项目的方法吗?是否有任何框架或库?

采纳答案by Noldorin

You're looking for the Mono Project- a cross-platform (but primarily targeted at Linux) implementation of the .NET Framework and CLR. It's capable of running binaries compiled for the CLR (MS .NET), or of creating its own native Linux binaries.

您正在寻找Mono 项目- .NET Framework 和 CLR 的跨平台(但主要针对 Linux)实现。它能够运行为 CLR (MS .NET) 编译的二进制文件,或创建自己的本机 Linux 二进制文件。

The project has been going a while now, and it's current version (2.4) is very usable, even for production purposes. See the project roadmapfor details of the main features and milestones of current and future releases.

该项目已经进行了一段时间,它的当前版本 (2.4) 非常有用,甚至可以用于生产目的。有关当前和未来版本的主要功能和里程碑的详细信息,请参阅项目路线图

Details about the current state:

有关当前状态的详细信息:

The great majority of the BCL (Base Class Library) is available on Mono, with the exception of some of the .NET 3.0/3.5 stuff, such as WPF (which has minimal support currently) and WCF (almost non-existent support). Silverlight 2.0 is however being supported via the Moonlightproject, and progress on that is going well. WinForms functionality (which uses GTK# as a backend) is however quite complete, as far as I know.

绝大多数 BCL(基类库)都在 Mono 上可用,除了一些 .NET 3.0/3.5 内容,例如 WPF(目前支持最少)和 WCF(几乎不存在支持)。然而,Silverlight 2.0 正在通过Moonlight项目得到支持,并且进展顺利。然而,据我所知,WinForms 功能(使用 GTK# 作为后端)非常完整。

Implementation of the C# 3.0 language is effectively complete, including the C# 3.0 features such as lambda expressions, LINQ, and automatic properties. I believe the C# compileris mature to the point that its efficiency is at least comparable with that of the MS compiler, though not yet matching it in some respects. What's quite cool (and unique) about the Mono C# compiler is that is now offers a compiler service- in other words true dynamic compilation from code (without using the CodeDOM). This is something that MS will perhaps only add in .NET 5.0.

C# 3.0 语言的实现实际上是完整的,包括 C# 3.0 特性,例如lambda 表达式LINQ自动属性。我相信C# 编译器已经成熟到它的效率至少可以与 MS 编译器相媲美的程度,尽管在某些方面还不能与之匹敌。Mono C# 编译器非常酷(和独特)的地方在于它现在提供了编译器服务- 换句话说,从代码中进行真正的动态编译(不使用 CodeDOM)。这是 MS 可能只会在 .NET 5.0 中添加的内容。

回答by Rytmis

Like others have already said, you can run .NET applications on Mono. If your applications use Platform Invocation (P/Invoke) to call native code, you may run into some trouble if there is no Mono implementation of the native library. To check whether your application does that (or uses APIs that haven't been implemented in Mono yet), you can use the Mono Migration Analyzer (MoMA).

就像其他人已经说过的那样,您可以在 Mono 上运行 .NET 应用程序。如果您的应用程序使用平台调用(P/Invoke)来调用本机代码,如果本机库没有 Mono 实现,您可能会遇到一些麻烦。要检查您的应用程序是否这样做(或使用尚未在 Mono 中实现的 API),您可以使用Mono Migration Analyzer (MoMA)

回答by LjCode

For those who come across this question post 2016, can use .NET Core- An open-source, general-purpose development platform maintained by Microsoft and the .NET community on GitHub. It's cross-platform (supporting Windows, macOS, and Linux) and can be used to build device, cloud, and IoT applications.

对于那些在2016 年之后遇到这个问题的人,可以使用.NET Core- 一个由 Microsoft 和 .NET 社区在 GitHub 上维护的开源通用开发平台。它是跨平台的(支持 Windows、macOS 和 Linux),可用于构建设备、云和 IoT 应用程序。