We have been writing and compiling the program to be run the dot net platform, but do we know how they actually run? This article explains you the working of our code on the dot net framework.
You write the code to be executed on the Dot Net framework. You can use any language like C#, or Visual Basic.
No matter you write your code in which language, the code will be converted into some binaries that will be run by all Dot Net framework based systems in a similar way.
Code Compilation & Intermediate Language
After writing the code, you compile the code to run it. The compilation process actually converts your written code into the binaries that can be understood by the machine only. No matter you write code in C# or Visual Basic, similar binaries will be created for your code to be run on Dot Net based platform. The binaries this created are known as Intermediate Language (IL) or Microsoft Intermediate Language (MSIL) or Common Intermediate Language (CIL).
The binaries are then run on the system running the Dot Net framework to run the actual application.
Common Language Runtime (CLR)
Common Language Runtime or CLR is a Virtual Machine that is controlled by the .Net framework. CLR is used to run a binary created by compiling the code.
CLR takes up the Intermediate Language and converts it into native instructions that are understood by the CPU.
Just In Time (JIT) Compilation
Just In Time or JIT Compilation is the process of taking those binaries of the Intermediate Language and converting them to native instructions that are understood by the machine.
CLR acts as an intermediary between the Intermediate Language and the machine level native instructions.
Besides this, CLR is responsible for many other operations. CLR is responsible for:
- Memory Management
- Garbage Collection
- Exception Handling
- Type Safety
- Thread management
Code Access Security (CAS)
Besides these, CLR also provides CAS(Code Access Security) i.e. the program being run by the CLR should only have the limited set of permissions that it should have access to. In other words, a program running on the CLR should not have permission to alter the data of other programs running on the same system. In this way, it makes running the programs safer.