.NET application execution order explained — Article: 2

iOSTom
2 min readFeb 25, 2021

In the last article I went over .NET Core, explained components and general overview of how they function. In this article I will explain how the compilation process works, how the complier takes code and coverts its to native machine code.

How are .NET applications executed?

In .NET the code execution process involves two stages Compile and Runtime.

What is Compile and Runtime processing?

During the compile time process, the compiler translates source code into Microsoft Intermediate Language (MSIL) code. In the runtime stage the CLR hosts a Just-In-Time (JIT) compiler which coverts MSIL code into native machine code that is then executed by the CPU. The CLR uses the Metadata and converts MSIL into native code.

Metadata describes types, definitions and the signatures which is used by the runtime at execution time.The runtime locates and extracts the metadata from the file as well as from the base class libraries (BCL) as needed during execution. The CIL is an abstract language used by a compiler as a step between the program code and the assembly code. A common language infrastructure (CLI) assembly is created by assembling the MSIL. This assembly is a compiled code library with two types: EXE and DLL. The EXE and DLL types can be run on any operating system with the CLR installed.

What is an assembly?

The assembly is similar to jar files, in .NET the compiler outputs executable as exe files which can be run on any operation system with the CLR installed.

What is Just-In-Time (JIT)compiler?

Today user’s can chose from different operating systems with custom configuration which can be problematic running running applications. A JIT compiler takes the IL and ensures it will run on the CLR host which converts the MSIL into machine code.

.NET Compilation and Runtime

I hope this article helped you understand what is going on when a .NET application is executed. HOw the execution process is broken down into two stages to create an executable that is compiled once that can run anywhere. If you enjoyed this article please give it a few likes or leave a comment below on how I could improve. Thanks again!!!

Next Article: Create .NET Application on Ubuntu

--

--

iOSTom

iOS Developer, Go, Java, C#, Blockchain enthusiast, Data junkie