What is CLR & CLR Components in Dotnet

Common Language Runtime :

  • The Common Language Runtime (CLR) is the agent that manages your .NET applications at execution time. In other words, CLR is the completely responsible component of .NET Framework that is responsible to manage the .NET applications at run time.
  • In other words, The Common Language Runtime (CLR) is the virtual machine in the .NET Framework.
  • It provides core services such as memory management, thread management, exception handling, security and resource management.
  • A .NET application is compiled into a "bytecode" format known as MSIL (Microsoft Intermediate Language). The MSIL bytecode allows .NET applications to be portable (at least theoretically) to other platforms because the application is compiled to native code only during runtime.
  • During execution, the CLR‘s JIT (just - in - time) compiles the bytecode into the processor‘s native code and executes the application.
  • The CLR contains the following components.
    1. JIT Compiler
    2. Memory Manager
    3. Garbage Collector
    4. Exception Manager
    5. Security Manager / Code safety verifier

1.) Just-In-Time Compiler

  • As you seen in the diagram of RTE previously, the JIT" compiler is responsible for compiling the "MSIL" code into the "Native code".
  • The native code is directly understandable by the system hardware.

2.) Memory Manager

The "Memory Manager" component of CLR, allocates necessary memory for the variables and objects that are to be used by the application.


3.) Garbage Collector

  • This component of CLR de-allocates or cleans-up the un-necessary memory of the application, after usage automatically.
  • Instead, in older languages such as C/C++ this kind of component is not available so that the programmer should free-up the memory explicitly using some code.

4.) Exception Manager

  • An exception means "Run time error".
  • This component redirect the processor to execute the "catch" block or "finally" block, whenever an exception is occurred at run time.
  • We can learn how to write these catch and finally blocks in C#.NET and VB.NET languages later.

5.) Security Manager / Code Safety Verifier

  • This is the initial and most component of CLR.
  • Application security is much more important issues today.
  • If you analyze this in-depth, we have 3 types of security support by .NET Framework.
    1. Evidence Based Security (EBS):

      • This security feature is meant for protecting entire assembly not to be accessed by un-authorized users.
      • The "Security Manager" component first checks privileges of the current user that the user is allowed to access the assembly or not, based on the "evidence".
      • The evidence is nothing but the information about the security permissions related to the assembly, that resides with in the assembly.
    2. Code Access Security (CAS):

      • This verifies whether the current user is allowed to perform the actions written in the MSIL code.
      • For example, accessing the file system, event log, printing, remote or network access etc.

Post a Comment

0 Comments