What is the CLR (Common Language Runtime)?
Quick Answer
The CLR is the execution engine for .NET. It loads assemblies, JIT-compiles Intermediate Language (IL) to native machine code, enforces type safety, manages memory with the garbage collector, and provides exception handling, threading and security. Code that runs under the CLR is called managed code.
The CLR is the runtime that actually executes .NET code. The C# compiler doesn't produce machine code — it produces IL plus metadata in an assembly. The CLR loads that, verifies it's type-safe, JIT-compiles each method to native code the first time it's called, and then manages everything at run time: the garbage collector, exceptions, threading, reflection and interop. Code running under it is “managed”. And because every .NET language compiles to the same IL, C# and VB.NET assemblies work together.
When you build a C# project, the compiler produces IL plus metadata, packaged in an assembly (.dll/.exe). At run time the CLR:
- Loads the assembly and reads its metadata.
- Verifies the IL for type safety.
- JIT-compiles each method to native code the first time it runs (then caches it). Ahead-of-time options like ReadyToRun and Native AOT exist too.
- Manages memory — allocates on the managed heap, runs the generational GC to reclaim unreachable objects.
- Provides services — exceptions, structured threading, reflection, interop with native code.
Because every .NET language compiles to the same IL and obeys the Common Type System, components written in C#, F# and VB.NET interoperate.