.NET 平台独立吗?

发布于 2024-09-18 17:28:08 字数 236 浏览 4 评论 0 原文

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

但它也独立于平台吗?如何 ?

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

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

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

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

.NET is a language independent platform.

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 !

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

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

Does OS independency related to platform independency ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(15

故人爱我别走 2024-09-25 17:28:09

摘自wiki

  • 不。DotNet 不是独立于平台的。
  • Microsoft .NET 在 Windows 上本机运行。然而,开源实现 Mono 允许它在开源系统上运行。但是,它并不支持所有 .NET 类,因此不要指望任何东西都能在那里完全运行。
  • 众所周知,在.NET中,有不同的编译器,例如C# - CSC VB - VBC等。您的代码编译后,它将转换为独立的MSIL代码。此 MSIL 代码将转到 CLR &这个CLR是平台相关的,即对于Unix平台,你应该有Unix类型的CLR,对于Windows也一样,所以我们可以说.NET代码是平台无关的。

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.
眼睛会笑 2024-09-25 17:28:09

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

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

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 Framework targets only some operating systems, like Windows. Other projects are available for other platforms, like Mono on Linux.

不打扰别人 2024-09-25 17:28:09

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

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

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

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

阳光下的泡沫是彩色的 2024-09-25 17:28:09

DotNet 不是平台独立的或可能部分独立的,而 Java 是完全平台的
由于其JVM(java虚拟机)而独立。
理解java独立性的最好例子你可以在你的“汽车”微波炉、洗衣机或任何一台安装了JVM(java虚拟机)的计算机上运行java程序。
Java字节码是独立的,免费的,无论我们使用mac、windows、unix都没关系。

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.

银河中√捞星星 2024-09-25 17:28:09

Mono 是 .NET 的跨平台实现,但不受 Microsoft 支持且缺失一些功能。

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

昨迟人 2024-09-25 17:28:09

Linux 上有一些 .net 实现,也许在其他系统上也可以编译。
它称为 Mono

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

邮友 2024-09-25 17:28:09

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

忘了说了,我说的是 Mono。

.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.

Forgot to mention that I'm talking about Mono.

雨落星ぅ辰 2024-09-25 17:28:09

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

如果平台 = 操作系统,则 .NET Framework 不是平台独立的,而 .NET Core 是。

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

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

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

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

所谓喜欢 2024-09-25 17:28:09

在 .NET 编程语言的编译过程中,源代码被转换为 CIL 代码,而不是特定于平台或处理器的目标代码。 CIL 是独立于 CPU 和平台的指令集,可以在任何支持公共语言基础结构的环境中执行,例如 Windows 上的 .NET 运行时或跨平台的 Mono 运行时。从理论上讲,这消除了为不同平台和 CPU 类型分发单独二进制文件的需要。 CIL 代码在运行时经过安全性验证,提供比本机编译的二进制文件更好的安全性和可靠性。
执行过程如下所示:
源代码被转换为通用中间语言,CLI 相当于 CPU 的汇编语言。
然后,CIL 被组装成字节码并创建 .NET 程序集。
执行 .NET 程序集时,其字节码将通过运行时的 JIT 编译器传递以生成本机代码。 (提前编译在运行时消除了此步骤。)
本机代码由计算机的处理器执行。然而,微软已经做出了一些在 .NET 上运行的改进,这些改进是专门针对 Windows 的,而 Mono(其基于 Linux 的对应版本)则远远落后。

During compilation of .NET programming languages, the source code is translated into CIL code rather than platform or processor-specific object code. CIL is a CPU- and platform-independent instruction set that can be executed in any environment supporting the Common Language Infrastructure, such as the .NET runtime on Windows, or the cross-platform Mono runtime. In theory, this eliminates the need to distribute separate binaries for different platforms and CPU types. CIL code is verified for safety during runtime, providing better security and reliability than natively compiled binaries.
The execution process looks like this:
Source code is converted to Common Intermediate Language, CLI's equivalent to Assembly language for a CPU.
CIL is then assembled into bytecode and a .NET assembly is created.
Upon execution of a .NET assembly, its bytecode is passed through the runtime's JIT compiler to generate native code. (Ahead-of-time compilation eliminates this step at run time.)
The native code is executed by the computer's processor. However Microsoft has made several improvements which run on .NET which are garnered specifically for windows leaving Mono (its linux based counterpart) much further behind.

獨角戲 2024-09-25 17:28:09

.NET 是独立于平台的,因为它可以在多个版本/风格的操作系统上运行(例如:MONO 在许多流行的操作系统上运行各种 .Net 框架版本。请参阅 http://mono-project.com/Compatibility)

.NET is platform independent, since it can be run on more than one version/flavor of OS (Ex: MONO runs various .Net framework versions on many popular operating systems. refer http://mono-project.com/Compatibility)

姜生凉生 2024-09-25 17:28:09

.NET 是平台相关的,因为一旦编写了代码,它就会被编译成独立于平台的 Microsoft 中间语言 (MSIL) 代码,但它是半编译代码,然后公共语言运行时 (CLR) 将其转换为设备特定的代码,即平台相关。(MSIL 通过 CLR 发送到 JIT。在运行时,所有内存分配均由 JIT 完成。)

.NET is Platform Dependent because once the code is written it is complied into Microsoft Intermediate Language(MSIL) code which is independent of platform but it is half compiled code,then Common Language Runtime(CLR) convert it into device specific code i.e it is platform dependent.(MSIL is send to JIT through CLR. At run-time all memory allocation is being done by JIT.)

不语却知心 2024-09-25 17:28:09

如您所知,.NET 使用了 4.0 框架。因此,编写的代码(源代码)转换为字节代码。该转换是通过MSIL(微软中间语言)完成的。MSIL是一种特殊类型的编译器,它将源代码编译为执行代码。其运行或支持任何平台。因此,由于使用 MSIL .NET 语言是跨平台语言。

As you know .NET used the framework 4.0.Because of this, the written code(source code) converted into byte code. That conversion is done through MSIL(Microsoft intermediate language).MSIL is special type of compiler that compile the source code into execution code. Which is run or support any platform. So Due to Use of MSIL .NET language is cross platform language.

徒留西风 2024-09-25 17:28:09

.Net 被认为是部分平台独立的,而不是完全平台独立的。然而,.Net支持某些其他操作系统,如win98、winnt、winserver 2000和新版本以及linux。同样的情况,clr对于win95不可用,这意味着.net不能在win95上执行。所以我们可以说,.net 是部分平台无关的,而不是完全平台无关的。

.Net is known as partially platform independent, not fully platforn independent. However, .Net supports certain other operating system like win98, winnt, winserver 2000 and new version as well as linux. In the same situation clr are not available for win95 that means .net can't be executed on win95. So we can say, .net is a partially platform independent not fully platform independent.

じ违心 2024-09-25 17:28:08

这实际上是一个如何定义“平台”的问题。

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

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

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.

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).

囚你心 2024-09-25 17:28:08

要回答这个问题,我认为首先必须明确区分 CLI 和 .NET:

  • CLI公共语言基础设施的缩写)是一种标准,因此它被设计为基本上平台无关。这里的平台是指计算机底层架构,包括操作系统。

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

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

    更新(2015 年 8 月):2014 年底,微软宣布计划逐步开源 .NET Framework 的部分内容(特别是与服务器端应用程序相关的部分) )。结果是 .NET Core。 org/" rel="nofollow noreferrer">.NET Foundation。

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

  • Mono 也是 CLI 的一种实现,但设计用于在不同平台(例如 Linux 和 Windows)上工作。 Mono 肯定比 .NET 更加独立于平台。


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

从这个意义上说,CLI(以及所有符合它的实现,例如 .NET)是语言无关的。

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

To answer this question, I believe that one must first make a clear distinction between the CLI and .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.

  • .NET is Microsoft's principal implementation of the CLI and runs only on Windows systems. Therefore, .NET is not platform-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 Core by the .NET Foundation.

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

  • Mono is 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.


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.

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

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 toolchain could 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文