Does the .exe file created by the C # compiler create only the Common Common Intermediate Language (CIL)?

I'm just trying to better understand what happens in a simple scenario when the following code is added to a file and saved with the .cs extension:

public class HelloWorld { public static void Main() { System.Console.WriteLine("Hello World!"); System.Console.ReadLine(); } } 

and then this program runs on a Windows command prompt with:

 C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /t:exe /out:C:\HelloWorld\HelloWorld.exe C:\HelloWorld\HelloWorld.cs 

I see that this process creates a .exe file, however, when you read about compiling the process in wikipedia , it reports:

  • The source code is converted to the Common Intermediate Language (CIL), which is the CLI equivalent of the assembly language for the CPU.
  • Then CIL is assembled in the form of so-called bytecode and a CLI assembly is created.
  • After the CLI assembly completes, its code is passed through the JIT compiler at runtime to generate its own code ...
  • Native code is executed by a computer processor.

And the .exe file itself consists only of Common Intermediate Lanaguage? And is this file what the wikipedia article calls the "CLI build"? I am a little confused because I can only see the .exe file, and for me the term “build” contains more than one file.

And the related question:

  • is the JIT compiler somewhere in the Microsoft.NET directory, and after executing the .exe file, does the file interact with the JIT compiler, which then outputs the instructions to native code?
+6
source share
2 answers

No, it is not.

Executable file PE-image .

For more information, see .NET Assembly Anatomy - PE Headers .

.NET assemblies are built on top of the PE (Portable Executable) file format, which 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 was not an embedded part of the operating system, as it is now. Prior to Windows XP, .NET executables had to be loaded, like any other executable, had to execute their own code to run the CLR to read and execute the rest of the file.

+11
source

It calls assembly because it contains more than one semantic data:

  • code
  • manifest
  • 0 or more modules

If you run a simple tool on any CLR assembly (EXE or DLL), for example: DotPeek , you will see IL instructions.

+1
source

Source: https://habr.com/ru/post/949647/


All Articles