Does the .exe file produced by the C# compiler consist solely of Common Intermediate Language(CIL)?

StackOverflow https://stackoverflow.com/questions/17700597

Question

I am just trying to get a better grasp on 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 is run at the windows command line with:

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

I can see this process produces an .exe file, however when reading about the compile process on wikipedia it states:

  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.

So does the .exe file itself consist solely of Common Intermediate Lanaguage? And is this file itself what the wikipedia article refers to as the 'CLI assembly'? I'm a bit confused because I can only see the .exe file and to me the term 'assembly' infers more than one file.

And related question:

  • is the JIT compiler somewhere in the Microsoft.NET directory and upon executing the .exe file the file communicates with the JIT compiler which then outputs the instructions in native code?
Was it helpful?

Solution

No, it doesn't.

The executable is a PE image.

See Anatomy of a .NET Assembly – PE Headers for details.

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

OTHER TIPS

It calls assembly, because contains more then one semantic data:

  • code
  • manifest
  • 0 or more modules

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top