Roadmap › .NET Internals — CLR, CTS, CLS, IL, JIT, Memory Management & Garbage Collection › Module: Platform and Compilation
Lessons in this course (11)
2. CLR, CTS, CLS — what each one does
Basic★ Must knowLesson 2 of 11
CLR responsibilities:
| Component | Job |
|---|---|
| Class loader | Loads assemblies and types, builds MethodTables |
| JIT compiler | IL → native code |
| Garbage collector | Allocates and frees managed memory |
| Type checker / verifier | Type safety — no invalid casts or reading random memory |
| Exception manager | Structured exception handling across frames and languages |
| Thread support | Managed threads, thread pool, synchronisation |
| Security | Type safety, (Framework: Code Access Security — removed in Core) |
| Interop | P/Invoke, COM interop, marshalling |
| Debugging / profiling APIs | Debuggers, profilers, diagnostics |
CTS — the type system all languages share:
text
System.Object
├── Value types (System.ValueType): int, double, bool, char, decimal, DateTime, struct, enum (System.Enum)
└── Reference types: class, string, array (System.Array), delegate (System.Delegate), interface, recordThe CTS defines visibility (public, private, internal, protected), inheritance rules (single class inheritance, multiple interfaces), members (fields, methods, properties, events) and how values are boxed. Because C# int and VB.NET Integer are both System.Int32, the languages interoperate perfectly.
CLS — the common subset for cross-language libraries. Examples of non-CLS-compliant features: unsigned types in public APIs (uint — VB.NET historically lacked them), names differing only by case (Name and name — VB.NET is case-insensitive), pointers. Mark libraries with [assembly: CLSCompliant(true)] and the compiler warns about violations.