如何在 Linux 环境下运行 .net 应用程序?

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

How to run .net application on Linux environment?

.netlinux

提问by pirate

Is it possible to run a .net application on Linux environment? If yes then how? Will all the components of .net framework work properly on Linux ?

是否可以在 Linux 环境中运行 .net 应用程序?如果是,那么如何?.net 框架的所有组件都能在 Linux 上正常工作吗?

采纳答案by Andrew Hare

Please see Running .Net applications on Linux with Mono:

请参阅使用 Mono 在 Linux 上运行 .Net 应用程序

Imagine the fate of your company rests on your completing your new Linux project on time. You have a crack team of first-class developers, but they're all .Net programmers. What are you going to do? Admit that Windows is better that Linux? Cry? Resign? No, you're going to install Mono and save the world!

想象一下,您公司的命运取决于您按时完成新的 Linux 项目。你有一个一流的开发团队,但他们都是 .Net 程序员。你会怎样做?承认 Windows 比 Linux 好?哭?辞职?不,您要安装 Mono 并拯救世界!

回答by Jon Skeet

While there are alternatives (I believe), Monois probably what you want.

虽然有其他选择(我相信),但Mono可能是您想要的。

It doesn't support everythingthat .NET supports, but there's a compatibility toolwhich will check for you. (I wouldn't blindly trust the results of the compatibility tool to be 100% accurate, as there will always be a few sneaky unknown incompatibilities, but it's a very good start.)

它不支持.NET 支持的所有内容,但有一个兼容性工具可以为您检查。(我不会盲目相信兼容性工具的结果是 100% 准确的,因为总会有一些偷偷摸摸的未知不兼容性,但这是一个非常好的开始。)

回答by RichardOD

There is also MainSoftthat lets you run on J2EE environment on Linux. It basically compiles the .NET source into Java bytecode.

还有MainSoft可以让您在 Linux 上的 J2EE 环境中运行。它基本上将 .NET 源代码编译成 Java 字节码。

回答by user3800527

A new answer for an old question, as technology improves. You might also consider running your app as a dotnet core application. The same code will work nativly with MAc Windows and linX download dotnet runtime for your OS and on a console type Dotnet .\yourapp.dll

随着技术的进步,旧问题的新答案。您还可以考虑将您的应用程序作为 dotnet 核心应用程序运行。相同的代码将适用于 MAC Windows 和 linX 下载 dotnet 运行时,适用于您的操作系统和控制台类型 Dotnet .\yourapp.dll

回答by Stuart Cardall

An updated answer for 2018with the current state of the Mono Project in Linux.

2018 年更新的答案以及Linux 中 Mono 项目的当前状态。

monorepos exist for:

mono回购存在于

Ubuntu
Debian
Raspbian
CentOS
Fedora
Docker

The instructions suggest installing mono-complete- on Centos I also had to install mono-basicfor VB.NET to work. The current level of support for VB.NET is:

说明建议安装mono-complete- 在 Centos 上,我还必须安装mono-basicVB.NET 才能工作。当前对 VB.NET 的支持级别是:

default runtime: v4.0.30319

which is good enough to run a VB.NETXMLclient which required a 3.5runtime:

这足以运行需要运行时的VB.NETXML客户端3.5

enter image description here

在此处输入图片说明

回答by Paul Weber

For running simple .net Applications mono is the tool of your choice! I used it for many applications and it worked without major glitches. I would not reccommend starting to develop on Mono though. Some people in my Class tried to do C# on Linux with mono, and failed terribly.

为了运行简单的 .net 应用程序,mono 是您选择的工具!我将它用于许多应用程序,并且没有出现重大故障。不过,我不建议开始在 Mono 上开发。我班上的一些人试图在 Linux 上用 mono 做 C#,但失败了。

When you do simple stuff it works good, but when you go to the more advanced stuff like using NHibernate or something like that, it may fail you. And you will miss out the best thing about .net - the Development Environment and that everything works together because everything is provided by Microsoft.

当你做简单的事情时它会很好,但是当你去做更高级的事情时,比如使用 NHibernate 或类似的东西,它可能会让你失望。而且您将错过 .net 最好的东西 - 开发环境,而且一切都可以协同工作,因为一切都由 Microsoft 提供。