public class HelloWorld { public static void Main() { System.Console.WriteLine("Hello World!"); System.Console.ReadLine(); } }
然后这个程序在windows命令行运行:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /t:exe /out:C:\HelloWorld\HelloWorld.exe C:\HelloWorld\HelloWorld.cs
我可以看到这个进程生成一个.exe文件,但是在阅读有关compile process on wikipedia时,它指出:
- Source code is converted to Common Intermediate Language (CIL),which is the CLI’s equivalent to Assembly language for a cpu.
- CIL is then assembled into a form of so-called bytecode and a CLI assembly is created.
- Upon execution of a CLI assembly,its code is passed through the runtime’s JIT compiler to generate native code…
- The native code is executed by the computer’s processor.
那么.exe文件本身只包含Common Intermediate Lanaguage吗?这个文件本身就是维基百科文章所称的’CLI程序集’吗?我有点困惑,因为我只能看到.exe文件,对我来说,’assembly’这个术语推断出多个文件.
相关问题:
>是Microsoft.NET目录中的JIT编译器,在执行.exe文件时,文件与JIT编译器通信,然后JIT编译器以本机代码输出指令?
解决方法
有关详情,请参阅Anatomy of a .NET Assembly – PE Headers.
.NET assemblies are built on top of the PE (Portable Executable) file format that is used for all Windows executables and dlls,which itself is built on top of the MSDOS executable file format. The reason for this is that when .NET 1 was released,it wasn’t a built-in part of the operating system like it is nowadays. Prior to Windows XP,.NET executables had to load like any other executable,had to execute native code to start the CLR to read & execute the rest of the file.