Sunday, 8 January 2012

Common Language Runtime(CLR)

What is CLR:
CLR stands for “Common Language Runtime”. CLR is the base for .NET Framework or we can say it is an “Application Virtual Machine” upon which the .NET Framework has been built. CLR manages code at runtime and the code managed by the CLR is called managed code.

CLR provides various services like exception handling, memory management, pre –emptive thread management, security and robustness for accessing code, cross-language integration, object lifetime management, resource management, type safety,  metadata services (type reflection) and profiling support to the applications.
Example: ASP.NET Framework, Internet Explorer (hosted by CLR)

CLR Features:
1.  CLR is an "execution engine” that manages the execution of programs.
 2. CLR provides execution environment for multiple languages. At that time there are more than
    15 that produce code that will execute in the CLR.
3. It is the implementation of CLI.
4. CLR provides secure file access operations, registry access operations
5. CLR provides a strict type and code verification infrastructure called Common Type System
   (CTS) that enforces code robustness
6.  CLR provides various properties like garbage clearance, object referencing, object handling. 
     These properties prevent memory leaks and invalid memory references.
7. Now programmers can select any language without worrying about the compatibility issues. 
    This increases the productivity of developers
6. CLR provides interoperability between managed and unmanaged code. 

How CLR works:
CLR works in the following way-

  • After compiling the .Net code, we found that the output of the compiler is not an executable file but a file that contains a special type of code called the Microsoft Intermediate Language (MSIL, now called CIL, Common Intermediate Language) .
  • So for changing MSIL into executable code the concept of CLR comes in to light.
  •   Now this MSIL is changed into executable code using a JIT (Just In Time) complier.It is the work of the CLR to activate the JIT complier. So we can say that JIT is responsible for converting MSIL into executable.

No comments:

Post a Comment