Why .NET code needs to be compiled for multiple platforms

When e. d. having created the Windows Phone application, I need to choose x86 for debugging in the emulator and ARM for debugging on the phone. This, of course, is because x86 works on my computer (x64, specifically, but x64 processors differ only in register length (please correct me if I am wrong)), and my phone has an ARM processor. But unlike C ++, C # is not compiled directly into assembler, but in some kind of intermediate langugage. So my question is: why is this intermediate language different for different platforms. Wouldn't it be enough to rewrite a virtual machine that interprets an intermediate language? E. g. Java runs on Mac, PC, etc. Without compilation for each platform.

+4
source share
2 answers

You just did it wrong. IL is exactly the same, regardless of platform choice.

When you create a new Phone project in Visual Studio 2013, you get a solution with three platform options: AnyCPU, x86, and ARM. The last two are redundant in a pure .NET project. The only reason they are present is because Phone also supports its own C ++ projects. Where the target architecture matters because C ++ is compiled directly into machine code.

In a pure .NET project, you only need AnyCPU. Named quite natural, of course;)

+4
source

(CIL, Common Intermediate Language) . ( ) . (: , ). Java.

Visual Studio, AnyCPU, .

+1

All Articles