CLR in .Net Framework (Common Language Runtime)

CLR (Common Language Runtime) in Net Framework, Is one of the most important component in .net framework architecture, we can say CLR is the heart of.Net Framework.

Common Language Runtime known as CLR is a run-time environment in .Net Framework.

What is Common Language Runtime in .Net?

CLR runs the MSIL code and convert that to native machine code.

How CLR works

Here is the process of how CLR works

  • When create any .net project (in any .net language ) and compile, that creates a assembly either .exe or .dll
  • Actually project gets converted into Common Intermediate Language (CIL) or Microsoft Intermediate Language (MSIL) often termed as IL (Intermediate Language)
  • Then CLR loads the metadata information of above assembly and other class libraries. Core Features of CLR :
    • Security Management
    • Memory management using Garbage Collector
    • JIT (just in time) compiler
    JIT compiler converts everything into native machine code.
CLR Services

Basically CLR runtime engine provide a set of Services.

  • Assembly Resolver:

    Read manifest of application, differentiate private and shared assembly those are required for application execution, then send request to assembly loader.

  • Assembly Loader:

    Based on assembly resolver intstructions, Assembly Loader load all assemblies into applicaiton process.

  • Type Checker:

    Type checker confirm that all types used in the assemblies as per standard of CTS or CLS, thus provide type safety.

  • COM marshaller:

    Marshal Classes reside under System.Runtime.InteropServices, this provides objects interoperability.

  • Thread Support:

    Thread support provide mechanism that multiple thread can run at the same time.

  • JIT Compiler:

    Converts IL code into operating native code.

  • Memory Management:

    Manage memory using Garbage collector , make sure unused instances are disposed after some certain time and release the memory, thus improve performance.

.Net Framework | Join .Net C# Course