The Common Language Runtime (CLR) is a very important part of the .NET Framework. At the base level, it is the infrastructure that executes applications, and allows them to interact with the other parts of the Framework. It also provides important capabilities in optimizing, securing, and providing many robust capabilities such as application deployment and side-by-side execution.
The CLR provides a number of services that include:
• Code management (loading and execution)
• Application memory isolation
Verification of type safety
• Conversion of IL to native code
• Access to metadata (enhanced type information)
• Managing memory for managed objects
• Enforcement of code access security
• Exception handling, including cross-language exceptions
• Interoperation between managed code, COM objects, and pre-existing DLLs (unman aged code and· data)
• Automation of object layout
• Support for developer services (profiling, debugging, and so on)
The activity of CLR is shown in figure that goes on when application is executed. The source code is compiled to IL (also refer as MSIL) while the metadata engine creates metadata information. IL and metadata are linked with other native code if required and the resultant code is saved. During execution IL, the IL code and any requirement from the base class library are brought together by the class loader. The' combined code is tested for type-safety and then compiled by the JIT compiler to produce native machine code, which is sent to the runtime manager (code manager) for code execution.
Components of CLR
The common language runtime simplifies application development, provider a robust and secure execution environment, supports multiple language and simplifies application deployment and management. The environment is also referred to as a managed environment, one in which common services, such as garbage collection and security, are automatically provided. The common language runtime features are described in the following table: