The CLR (Common Language Runtime) · TL;DR

1 min read
Mid-level12 min read
Rapid overview

TL;DR

The CLR is the virtual machine that runs .NET code. The C# compiler does not produce machine code: it produces IL (Intermediate Language, also called CIL or MSIL) plus metadata describing every type and member, packaged in an assembly (.dll). At runtime the CLR loads assemblies, builds in-memory type structures, JIT-compiles each method's IL to native machine code the first time it is called, and then provides the services managed code relies on: memory allocation and garbage collection, type safety (bounds, null and cast checks), exception handling, threads, interop with native code, reflection and security boundaries. Because of the shared IL and type system (CTS), C#, F# and VB.NET all run on it and can call each other. Implementations: the Windows-only .NET Framework CLR (legacy), cross-platform CoreCLR used by .NET 5+, and Mono (mobile, WebAssembly). Modern performance features to know: tiered compilation, dynamic PGO, ReadyToRun and Native AOT. Garbage collection in depth is in the Core C# note "CLR & Garbage Collector (GC)".

See also