加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C#编译器生成的.exe文件是否仅由通用中间语言(CIL)组成?

发布时间:2020-12-15 18:14:38 所属栏目:百科 来源:网络整理
导读:我只是想更好地掌握以下代码添加到文件并使用.cs扩展名保存时在简单场景中发生的事情: public class HelloWorld{ public static void Main() { System.Console.WriteLine("Hello World!"); System.Console.ReadLine(); }} 然后这个程序在windows命令行运行
我只是想更好地掌握以下代码添加到文件并使用.cs扩展名保存时在简单场景中发生的事情:
public class HelloWorld
{
  public static void Main()
  {
    System.Console.WriteLine("Hello World!");
    System.Console.ReadLine();
  }
}

然后这个程序在windows命令行运行:

C:WindowsMicrosoft.NETFrameworkv4.0.30319>csc /t:exe /out:C:HelloWorldHelloWorld.exe C:HelloWorldHelloWorld.cs

我可以看到这个进程生成一个.exe文件,但是在阅读有关compile process on wikipedia时,它指出:

  1. Source code is converted to Common Intermediate Language (CIL),which is the CLI’s equivalent to Assembly language for a CPU.
  2. CIL is then assembled into a form of so-called bytecode and a CLI assembly is created.
  3. Upon execution of a CLI assembly,its code is passed through the runtime’s JIT compiler to generate native code…
  4. The native code is executed by the computer’s processor.

那么.exe文件本身只包含Common Intermediate Lanaguage吗?这个文件本身就是维基百科文章所称的’CLI程序集’吗?我有点困惑,因为我只能看到.exe文件,对我来说,’assembly’这个术语推断出多个文件.

相关问题:

>是Microsoft.NET目录中的JIT编译器,在执行.exe文件时,文件与JIT编译器通信,然后JIT编译器以本机代码输出指令?

解决方法

不,它没有.

可执行文件是PE image.

有关详情,请参阅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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读