Execution process for managed code

Execution Process

Managed execution process includes the following steps:


Choosing the right compiler

.Net Framework is a multilanguage execution environment, the runtime supports a wide variety of data types and language features. In order to obtain the full benefits provided by the common language runtime , you should use one or more language (VB.Net, C# etc.) compilers that target the runtime

Compiling the code to MSIL

Unlike the execution style of compiling source code into machine level code, .Net language compilers translates the source code into Microsoft Intermediate Language. This ensures language interoperability because no matter which language has been used to develop the application, it always gets translated to Microsoft Intermediate Language. During the compile time the compiler produces metadata, that contains description of the program like dependencies, versions etc

Compiling MSIL to native code

Before the program execution , Jist In Time compiler (JIT) compiles the MSIL into native code and stores it in a memory buffer. During JIT compilation, the code is also checked for type safety. Type safety ensures that objects are always accessed in a compatible way. The compiled native code is in memory and is not persisted. So every time we run our application this whole thing has to happen again.

Excecution of Code

After translating the IL into native code, it is sent to .Net runtime manager. The .Net runtime manager executes the code. During execution, managed code receives services such as garbage collection, security, interoperability with unmanaged code, cross-language debugging support, and enhanced deployment and versioning support.