What is CLR ? - Part 10

Today, we will talk about the most important component of .NET Framework.

Common Language Runtime(CLR):

  • It is a core runtime and managed execution environment for Microsoft's .NET Framework. It manages the execution of code in different supported languages.
  • CLR transforms the source code into native code or byte code and then the program gets executed.
  • It works as a layer between Operating Systems and Applications written in .NET languages that conforms to Common Language Specification.
  • CLR Component JIT Compiler converts the IL code to native code on demand at application run-time.
  • The language compilers stores metadata that describes the members, references and types in the compiled code. The CLR uses the metadata to layout instances in memory, locate and load classes, enforce security, set runtime context boundaries and generate native code.
  • It provides services such as memory management, thread management, security management, code verification, compilation and other services.

Architecture of CLR:


Base Class Library:
  • It provides class libraries support to an application when IL code is converted to an Native code.
  • Conversion is done through JIT compiler and its end result is Portable Executable(PE) File.

Thread Support:
  • Thread is basically a light-weight processes responsible for multi-tasking within Single/Multiple Applications.
  • Threads are managed through CLR and it maintains parallel code execution.

COM Marshaller:
  • It enables communication between application and COM objects.

Type Checker:
  • CLR manages code execution by converting source code to IL code through language compilers which in turn converts IL code to native code.
  • IL code is also called managed code because CLR manages the code.

Exception Manager:
  • It allows us to perform debugging at application run time.

Common Language Specification(CLS):
  • CLS defines the rules and standards to which languages must adhere in order to be compatible with other .NET languages. 
  • It allows C# to inherit classes defined from different languages.

Common Type System(CTS):
  • It allows CLR to determine datatypes defined in two different languages to communicate with common base system.

Type Checker:
  • It allows CLR to verify types used in the application with CLR or CTS standards, to ensure type-safety.

Exception Manager:
  • Exception Manager will handle exceptions thrown by application while executing try/catch block provided by an exception.
  • In "Try" block where a part of code expects an error.
  • Whereas "Catch" block throws an exception caught from Try block, if there is no catch block, it will terminate application.

Security Engine:
  • It enforces security permissions at code-level security, folder-level security, and machine-level security using .NET Framework setting and tools provided.

Garbage Collector:
  • It handles automatic memory management and it releases memory of unused objects in an application.

No comments:

Post a Comment