How Does CLR Work In Dot NET Framework?

Before starting with CLR you need to understand .NET Framework first. So, actually what is the .NET Framework?

Well, it is a software framework in which we design and create wonderful applications (windows, web & mobile). This framework is introduced by Microsoft and backed by its community which means it has a great future with head support.

There is a total of 8 numbers release of release come to till now given below:
  • .NET Framework 1.0     {Release date 2002-02-13}
  • .NET Framework 1.1     {Release date 2003-04-24}
  • .NET Framework 2.0    {Release date 2005-11-07}
  • .NET Framework 3.0    {Release date 2006-11-06}
  • .NET Framework 3.5    {Release date 2007-11-19}
  • .NET Framework 4.0    {Release date 2010-04-12}
  • .NET Framework 4.5    {Release date 2012-08-15}
  • .NET Framework 4.6   {Release date 2015-07-20}
  • .NET Framework 4.7   {Release date 2017-04-05}

What Are The Components Of .NET Framework?

.NET Framework contains lots of components and CLR is the Key component for it and following is another component in Dot Net Framework, which we will discuss in other posts.

  1. .NET Framework Class Library.
  2. Common Language Runtime. – Will discuss in this blog
  3. Dynamic Language Runtimes (DLR)
  4. Application Domains.
  5. Runtime Host.
  6. Common Type System.
  7. Metadata and Self-Describing Components.
  8. Cross-Language Interoperability.

Introduction To CLR

The Common Language Runtime (CLR) is the main machine or key component of Microsoft Dot Net Framework and it manages the total execution of .NET programs. A process known as JIT ( just-in-time compilation) converts compiled code into machine language, which the computer’s CPU then executes.

Under .NET Framework, there are categories of the code into two types first manage code which runs and is executed under the CLR environment, and unmanaged code which not run and execute under the CLR environment.

What Is Managed Code?

Managed code is the resultant output of source code done by the compiler and that code is written in one of over 20 high-level programming languages that are used with the Microsoft .NET Framework. Examples of those languages are C#, J#, Microsoft Visual Basic Dot NET, Microsoft JScript, and Dot NET. On the other hand, unmanaged code refers to programs written in C, C++, and other languages that do not need a runtime to execute.

Features Of Common Language Runtime

CLR - Common Language Runtime

CLR provides additional services including Base Class Library Support, thread management, memory management, type safety, exception handling, garbage collection, and security. All programs are written for the .NET framework, regardless of programming language, and are executed by the CLR. All versions of the .NET framework include CLR.

Base Class Library Support

It provides supports through class libraries to an application.

Thread Management

The execution of code parallel is called Threading and threads are runs under the Common Language Runtime. Threads are basically lightweight processes responsible for multitasking within a single application.

COM Marshaler

Helps in communication between the COM objects and application.

Type checker

Type Checkers Like CLS or CTS will verify types used in the application standards supported by CLR. This provides type safety. The MSIL code, which is the compiled output of the written code in any language supported by .NET Framework, is the same and at this stage, a code has a feature of interoperability.

Common Language Specification (CLS)

Common Language Specification (CLS) under CLR is a set of rules by which languages must flow in order to make them compatible with other .NET languages.

CTS (Common Type System)

Data types of class members that are created in two different languages get compiled into the base common data type system.

The following can be regarded as the functions of the Common Type System. It:

  • Makes it possible for the framework to be cross-language integration or platform independent, type safety, and high-performance code execution.
  • Defines rules that languages must follow, which helps ensure that objects written in different languages can interact with each other.
  • Provides primitive data types (such as Boolean, Byte, Char, Int32, and UInt64) used in application development.

This topic contains the following sections:

Types in DOT NET

Type Definitions

Type Members

Characteristics of Type Members

Types of DOT NET

All types in .NET are either value types or reference types.

Value types are data types whose objects are represented by the object’s actual value. If an instance of a value type is assigned to a variable, that variable is given a fresh copy of the value.

Reference types are data types whose objects are represented by a reference (similar to a pointer) to the object’s actual value. If a reference type is assigned to a variable, that variable references points to the original value. No copy is made.

The common type system in .NET supports the following five categories of types:

  • Classes
  • Structures
  • Enumerations
  • Interfaces
  • Delegates

Security Engine

It enforces security permissions at code level security, folder-level security, and machine-level security using Dot Net Framework setting and tools provided by Dot Net.

Garbage Collection

Garbage Collector automatically releases memory of unused objects in an application and can be done by CLR automatically or forcefully by writing a code in an application about how memory management happens in CLR.


In short, our code gets compiled two times. On the first pass, it is compiled from higher language to MSIL (Microsoft Intermediate Language). During the second pass, the code (now an assembly in MSIL) is compiled into machine language which is understandable by the operating system.

This process is called Just-In-Time JIT compilation because it does not occur until the assembly is on the target machine. Due to this, the assembly is compiled in a very optimized and fastest possible machine language code. Also, it is also enhanced for your specific configuration.



Pre-JIT compiles complete source code into native code in a single compilation cycle. This is performed at the time of deployment of the application.


Econo-JIT compiles only those methods that are called at runtime. However, these compiled methods are removed when they are not required.


Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in a cache. When the same methods are called again, the compiled code from a cache is used for execution.

These methods are compiled the first time they are called, and then they are stored in a cache. When the same methods are called again, the compiled code from a cache is used for execution.

Final Words

Any confusion or suggestions? Feel Free to add your valuable comments in the same regard!

19 thoughts on “How Does CLR Work In Dot NET Framework?”

  1. Pingback: Homepage

Leave a Comment