Is .NET platform independent?

旧城冷巷雨未停 提交于 2019-11-27 03:37:17

问题


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


回答1:


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




回答2:


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




回答3:


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.



回答4:


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.




回答5:


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




回答6:


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.




回答7:


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




回答8:


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




回答9:


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




回答10:


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.




回答11:


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




回答12:


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.




回答13:


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




回答14:


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




回答15:


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



来源:https://stackoverflow.com/questions/3656721/is-net-platform-independent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!