The common language runtime (CLR) is major component of .NET Framework and it is the execution engine for .NET Framework applications.
It is responsible for providing the number of services, including the following:
* . Code management (loading and execution)
*. Verification of type safety
*. Conversion of Microsoft Intermediate Language (MSIL) to native code
*. Access to metadata (enhanced type information)
*. Managing memory for managed objects
*. Enforcement of code access security (See what is code access security?)
*. Exception handling, including cross-language exceptions
*. Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code and data)
*. Automation of object layout
*. Support for developer services (profiling, debugging, and so on)
What is the common type system (CTS)?
The common type system (CTS) is a rich type system, built into the common language runtime (CLR) that supports the types and operations found in most of .NET programming languages. The common type system supports the complete implementation of a wide range of programming languages.
What is the Microsoft Intermediate Language (MSIL)?
MSIL is the Machine independent Code into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects. Combined with metadata and the common type system, MSIL allows for true cross language integration. Prior to execution, MSIL is converted to machine code via CLR’s Just-in-Time (JIT) compiler.
What is managed code and managed data?
We can describe Managed code like, if a code running under the control CLR, then that code is called as Managed Code.
Managed code is code that is written to target the services of the common language runtime (see what is CLR?). In order to target these services, the code must provide a minimum level of information (metadata) to the runtime. All C# (when not using the unsafe keyword), Visual Basic .NET, J#, and JScript .NET code is managed by default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by specifying a Command-line switch (/CLR). Closely related to managed code is managed data—data that is allocated and reallocated by the common language runtime's garbage collector. C#, Visual Basic.NET, J# and JScript .NET data is managed by default. C# data can, however, be marked as unmanaged through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default (even when using the /CLR switch), but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector. In addition, the class becomes a full participating member of the .NET Framework community, with all of the benefits and restrictions that brings. An example of a benefit is proper interoperability with classes written in other languages (for example, a managed C++ class can inherit from a Visual Basic.NET class). An example of a restriction is that a managed class can only inherit from one base class. Any restrictions, such as this one, are designed to prevent common programming errors.