.NET 平台是否独立?

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

Is .NET platform independent?

.netplatform-independent

提问by stakx - no longer contributing

.NET is a language independent platform.

.NET 是一个独立于语言的平台。

But is it platform independent as well ? How ?

但它也是平台独立的吗?如何 ?

EDIT : I have heard, .NET 4.0 is developed considering plateform independency ! Well, hope it may take over Java, if so !

编辑:我听说,.NET 4.0 是在考虑平台独立性的情况下开发的!好吧,如果是的话,希望它可以取代 Java!

EDIT : The answer depends upon the way how we define 'platform', like .NET for windows platform and Mono for Java.

编辑:答案取决于我们定义“平台”的方式,例如 Windows 平台的 .NET 和 Java 的 Mono。

But, the question is, don't do we have general development platform which is OS independent !

但是,问题是,我们有没有独立于操作系统的通用开发平台!

Does OS independency related to platform independency ?

操作系统独立性与平台独立性有关吗?

回答by Cumbayah

It's really a matter of how you define "platform".

这真的是你如何定义“平台”的问题。

E.g. .NET is platform independent as long as the platform is .NET, the same way that Java is platform independent as long as the platform is Java. That is to say, .NET (and Java) are, in part, platforms in themselves (CLR, JVM). As long as there is an implementation of that platform available for a given physical platform, yes, you can run the compiled code on it independently.

例如,只要平台是 .NET,.NET 就是平台无关的,就像 Java 是平台无关的,只要平台是 Java。也就是说,.NET(和Java),一部分是本身的平台(CLR,JVM)。只要该平台的实现可用于给定的物理平台,是的,您就可以在其上独立运行已编译的代码。

In the end, "platform independence" is, just as "write once, run anywhere", marketing. But in practice, currently, there are JVM implementations available for a lot more concrete platforms than .NET (although initiatives such as the Mono projects aims to change that).

归根结底,“平台独立”就像“一次编写,随处运行”一样,是营销。但在实践中,目前有 JVM 实现可用于比 .NET 更具体的平台(尽管 Mono 项目等举措旨在改变这一点)。

回答by stakx - no longer contributing

To answer this question, I believe that one must first make a clear distinction between the CLI and .NET:

要回答这个问题,我相信首先要明确区分CLI和.NET:

  • The CLI(short for Common Language Infrastructure) is a standard, and as such it is designed to be mostly platform-independent. Here, platform refers to the underlying computer architecture, including the operating system.

    While it is possible that the standard requires certain things which are not possible to implement on all architectures (I'm thinking of very limited platforms, such as embedded systems), but these can perhaps be considered edge cases.

  • .NETis Microsoft's principal implementation of the CLI and runs only on Windows systems. Therefore, .NET is notplatform-independent.

    Update (August 2015): At the end of 2014, Microsoft announced that it planned to progressively open-source parts of the .NET Framework (specifically those parts that are relevant for server-side applications). The result is .NET Coreby the .NET Foundation.

  • .NET Coreis intended to be a cross-platform implementation of the CLI.

  • Monois also an implementation of the CLI, but one designed to work on different platforms such as Linux and Windows. Mono is definitely more platform-independent than .NET.

  • CLI(简称通用语言基础结构)是一种标准,因此它被设计为主要平台无关。这里,平台是指底层的计算机架构,包括操作系统。

    虽然该标准可能需要某些无法在所有架构上实现的东西(我正在考虑非常有限的平台,例如嵌入式系统),但这些可能被视为边缘情况。

  • .NET是 Microsoft 的 CLI 的主要实现,仅在 Windows 系统上运行。因此,.NET不是平台无关的。

    更新(2015 年 8 月):2014 年底,Microsoft 宣布计划逐步开源 .NET Framework 的部分(特别是与服务器端应用程序相关的部分)。其结果是.NET的核心.NET基金会

  • .NET Core旨在成为 CLI 的跨平台实现。

  • Mono也是 CLI 的一种实现,但设计用于在 Linux 和 Windows 等不同平台上工作。Mono 绝对比 .NET 更独立于平台。



Second, there is the issue of binary compatibility of a compiler's output. Because the CLI standard defines the file format (a form of PE executable files) and intermediate code language (called CIL) to be used for assemblies, you can mix components written in VB.NET, C#, and some other languages freely once source code has been compiled to CIL.

其次,存在编译器输出的二进制兼容性问题。由于 CLI 标准定义了用于程序集的文件格式(PE 可执行文件的一种形式)和中间代码语言(称为 CIL),因此您可以在源代码后自由混合使用 VB.NET、C# 和其他一些语言编写的组件已编译为CIL

In that sense, the CLI (and with it all of its conforming implementations, such as .NET) is language-independent.

从这个意义上说,CLI(及其所有符合要求的实现,例如 .NET)是独立于语言的

Interestingly, you can compile something with Microsoft's .NET compilers, and because of the common assembly file format prescribed by the standard, you should be able to use the assembly in a Mono project — and vice versa. In this sense, the .NET compiler toolchaincould be considered platform-independent — but not .NET itself. Remember that the .NET Framework also encompasses a standard library which is targeted at Windows (think WPF, for example).

有趣的是,您可以使用 Microsoft 的 .NET 编译器进行编译,并且由于标准规定的通用程序集文件格式,您应该能够在 Mono 项目中使用该程序集,反之亦然。从这个意义上说,.NET编译器工具链可以被视为独立于平台的——但不是 .NET本身。请记住,.NET Framework 还包含一个针对 Windows 的标准库(例如 WPF)。

回答by Sachin Shanbhag

Taken from wiki:

取自维基

  • No. DotNet is not platform independent.
  • Microsoft .NET runs on Windows natively. However an open source implementation, Mono, allows for it to run on open source systems. It, however, doesn't support all .NET classes, so don't expect anything to run completely there.
  • As you all know that in .NET, there are different compilers like for C# - CSC VB - VBC etc. After your code is complied it will convert to MSIL code which is independent. This MSIL code will be go to CLR & this CLR is platform dependent i.e for Unix platform, you should have Unix-type of CLR, for Windows like the same so we can say that .NET code is platform independent.
  • 不。DotNet 不是独立于平台的。
  • Microsoft .NET 本机在 Windows 上运行。然而,开源实现 Mono 允许它在开源系统上运行。但是,它不支持所有 .NET 类,所以不要指望任何东西都能在那里完全运行。
  • 众所周知,在 .NET 中,有不同的编译器,例如 C# - CSC VB - VBC 等。在您的代码编译后,它将转换为独立的 MSIL 代码。这个 MSIL 代码将转到 CLR 并且这个 CLR 是平台相关的,即对于 Unix 平台,你应该有 Unix 类型的 CLR,对于 Windows 也是如此,所以我们可以说 .NET 代码是平台无关的。

回答by Arseni Mourzenko

Not sure what do you mean by your question, but if you want to know if a .NET application can run on any OS, that the answer is no.

不确定您的问题是什么意思,但如果您想知道 .NET 应用程序是否可以在任何操作系统上运行,答案是否定的。

.NET Framework targets only some operating systems, like Windows. Other projects are available for other platforms, like Mono on Linux.

.NET Framework 仅针对某些操作系统,例如 Windows。其他项目可用于其他平台,例如 Linux 上的 Mono。

回答by softcr

There is a cross platform implementation called "mono". The original .NET releases from Microsoft are Windows only.

有一个名为“mono”的跨平台实现。Microsoft 的原始 .NET 版本仅适用于 Windows。

More info about the mono project: http://en.wikipedia.org/wiki/Mono_Project

有关单声道项目的更多信息:http: //en.wikipedia.org/wiki/Mono_Project

回答by Vishal Sharma

DotNet is not platform independent or may be partially independent While Java is fully platform independent because of its JVM(java virtual machine). the best example to understand java independency u can run a java program in your "car" microwave,washing machine, or either computer if JVM(java virtual machine) is installed. Java byte code is independent free it doesnt matter while we used mac,windows,unix whatever.

DotNet 不是平台独立的,也可能是部分独立的,而 Java 由于其 JVM(java 虚拟机)而完全独立于平台。了解 Java 独立性的最佳示例您可以在“汽车”微波炉、洗衣机或安装了 JVM(Java 虚拟机)的任何一台计算机中运行 Java 程序。Java字节码是独立自由的,我们用mac、windows、unix什么的都没有关系。

回答by pbkrishna chaitanya

Okay. Whether .NET Framework is Platform Independent or not largely depends upon what 'Platform' actually means.

好的。.NET Framework 是否独立于平台在很大程度上取决于“平台”的实际含义。

If Platform = Operating System, then .NET Framework is not Platform Independent, .NET Core is.

如果Platform = Operating System,则 .NET Framework 不是平台独立的,.NET Core 是。

If Platform = Independent System/PC, then yes .NET Framework is Platform Independent, because of CLR/CLI(Just like Java's JVM).

如果Platform = Independent System/PC,那么 .NET Framework 是平台独立的,因为 CLR/CLI(就像 Java 的 JVM)。

回答by bua

There are some .net implementations on linux maybe on other systems would be compiled as well.
It's called Mono.

在 linux 上有一些 .net 实现,也许在其他系统上也会被编译。
它被称为Mono

回答by Sjoerd

Monois a cross platform implementation of .NET, but it is not supported by Microsoft and is missing some functionality.

Mono是 .NET 的跨平台实现,但它不受 Microsoft 支持并且缺少某些功能。

回答by jgauffin

.Net works fine on MacOSX and Linux as long as you stick to .Net 2.0. Some newer features like LINQ, C# 3.0 etc have also been implemented. You need to take into consideration that file paths, file permissions etc are not working 100% similiar in different platforms.

只要您坚持使用 .Net 2.0,.Net 就可以在 MacOSX 和 Linux 上正常运行。还实现了一些较新的功能,如 LINQ、C# 3.0 等。您需要考虑到文件路径、文件权限等在不同平台上的工作方式并非 100% 相似。

Forgot to mention that I'm talking about Mono.

忘了说我说的是 Mono。