MSDN Documentation

.NET Common Language Runtime (CLR)

CLR Overview

The .NET Common Language Runtime (CLR) is the execution engine of the .NET Framework. It provides the run-time environment for .NET programs and is responsible for managing code execution, memory management, and exception handling.

Key responsibilities of the CLR include:

  • Just-In-Time (JIT) Compilation: Compiles Intermediate Language (IL) code into native machine code at runtime.
  • Memory Management: Handles memory allocation, deallocation, and garbage collection.
  • Type Safety: Ensures that code operates on valid data types.
  • Exception Handling: Provides a structured way to handle runtime errors.
  • Security: Enforces security policies and permissions.
  • Interoperability: Allows .NET code to interact with unmanaged code.

The CLR is a fundamental component of the .NET ecosystem, enabling powerful and robust application development.

Key Concepts

Understanding these core concepts is crucial for working effectively with the CLR:

Related API Reference

Explore the .NET APIs that interact with or are managed by the CLR:

Getting Started with CLR Programming

To begin exploring CLR programming, you typically start with a high-level language like C# or Visual Basic, which compile down to IL that the CLR executes. Here's a simple example:


// A basic C# program demonstrating CLR execution
using System;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello, CLR!");
    }
}
                

When this code is compiled, it produces an assembly containing IL. The CLR then loads this assembly, performs JIT compilation, and executes the managed code.