Introduction to .NET Framework
The .NET Framework is a software platform from Microsoft, built into Windows, for building and running applications. It consists of a virtual execution system called the Common Language Runtime (CLR) and a large set of class libraries that support the execution of applications written in different programming languages such as C#, VB.NET and F#.
Think of the .NET Framework as a fully equipped kitchen. The CLR is the chef who actually cooks (runs your program), and the class library is the shelf of ready-made ingredients and tools (file access, databases, networking, collections). You bring the recipe (your code); you don't have to build the stove or grow the vegetables yourself.
What the .NET Framework provides
- Language interoperability: the .NET Framework bridges the gap between applications written in different languages. A class written in VB.NET can be used from C#, because both are compiled to the same intermediate language.
- A rich class library: it contains thousands of ready-made classes, interfaces and value types that speed up development and give easy access to system functionality such as files, networking, databases and security.
- A managed runtime: the CLR provides memory management, exception handling, debugging, security, thread management, code execution, type safety, code verification and compilation.
- Automatic memory management: the CLR's garbage collector automatically frees memory that is no longer in use. This prevents most memory leaks and invalid memory references that are common in languages like C and C++.
- Easy deployment: applications are deployed as assemblies (
.exeand.dllfiles) that describe themselves, so in most cases no registry entries are needed to store information about components and applications. Many applications can be installed simply by copying their folder.
.NET Framework architecture
The .NET Framework is built in layers. Your application sits on top, uses the class library, and runs inside the CLR, which talks to Windows:
How a .NET program runs
- You write code in C# (or VB.NET, F#).
- The language compiler (for example
cscfor C#) compiles it into Intermediate Language (IL) and stores it in an assembly (.exeor.dll) together with metadata. - When the program starts, the CLR loads the assembly, verifies it, and its JIT (Just-In-Time) compiler converts the IL into native machine code for the computer's processor.
- The native code runs under the control of the CLR, which manages memory, security and exceptions.
C# source code --(C# compiler)--> IL in .exe/.dll --(JIT)--> native code
Program.cs MyApp.exe x86 / x64 / ARM64
Because every .NET language compiles to the same IL and follows the same type rules, code written in different languages can work together.
Components of .NET Framework
The .NET Framework has many components. They can be grouped as follows:
| Group | Component | What it does |
|---|---|---|
| Runtime | Common Language Runtime (CLR) | Runs .NET code: JIT compilation, memory management, security, exceptions |
| Common Type System (CTS) | Defines the data types all .NET languages share | |
| Common Language Specification (CLS) | Rules that languages follow so their code can be used from other .NET languages | |
| Libraries | Framework Class Library (FCL), including the Base Class Library (BCL) | Ready-made classes for collections, files, networking, security, threading and more |
| Application models | Windows Forms | Desktop applications with forms and controls |
| Windows Presentation Foundation (WPF) | Rich desktop user interfaces with XAML | |
| ASP.NET (Web Forms, MVC, Web API) and ASP.NET AJAX | Web applications and web services | |
| Console applications | Command-line programs | |
| Data access | ADO.NET (ActiveX Data Objects for .NET) | Connecting to databases and running SQL |
| Entity Framework and WCF Data Services | Object-relational mapping and data services | |
| Language Integrated Query (LINQ) | Querying collections, databases and XML with C# syntax | |
| Services | Windows Communication Foundation (WCF) | Building service-oriented applications (SOAP and other protocols) |
| Windows Workflow Foundation (WF) | Building workflow-based applications | |
| Languages | C#, VB.NET, F# and C++/CLI compilers | Compile source code into IL |
Benefits of .NET Framework
- Consistent programming model: the same classes and patterns are used for desktop, web and service applications.
- Language interoperability: components written in different .NET languages work together.
- Automatic management of resources: garbage collection frees memory automatically.
- Ease of deployment: self-describing assemblies, side-by-side versions and simple copy-based installation.
- Security: type safety, code verification and built-in security libraries.
- Runs on all supported versions of Windows: one application works on desktop and server editions of Windows. (For Linux and macOS, use modern .NET.)
.NET Framework 4.0 also added several features developers still use every day:
- Support for dynamic data types (
dynamic) - Named and optional arguments
- Easier access to Office interop objects
- An improved integrated debugger in Visual Studio 2010
Evolution of .NET Framework
| Version | Released | Visual Studio | Highlights |
|---|---|---|---|
| 1.0 | 13 February 2002 | Visual Studio .NET 2002 | First release: CLR, class library, ASP.NET Web Forms, Windows Forms, ADO.NET |
| 1.1 | 2003 | Visual Studio .NET 2003 | ASP.NET mobile controls, ODBC and Oracle data providers |
| 2.0 | 2005 | Visual Studio 2005 | Generics, nullable types, partial classes, anonymous methods |
| 3.0 | 2006 | Visual Studio 2005 (with extensions); shipped with Windows Vista | WPF, WCF and Windows Workflow Foundation |
| 3.5 | 2007 | Visual Studio 2008 | LINQ, lambda expressions, ASP.NET AJAX |
| 4.0 | 2010 | Visual Studio 2010 | dynamic, named and optional arguments, Task Parallel Library |
| 4.5 | 2012 | Visual Studio 2012 | async and await |
| 4.6 | 2015 | Visual Studio 2015 | New 64-bit JIT compiler (RyuJIT) |
| 4.7 | 2017 | Visual Studio 2017 | High-DPI and accessibility improvements |
| 4.8 | 2019 | Visual Studio 2019 | Performance and security updates |
| 4.8.1 | 2022 | Visual Studio 2022 | Native ARM64 support; the final version of .NET Framework |
.NET Framework 4.8.1 is still supported as part of Windows, but no new features are added to it. New applications are built on the modern, cross-platform .NET (formerly .NET Core). See .NET Framework vs .NET Core for the differences.
Interview questions
1. What is the .NET Framework?
A Windows platform from Microsoft for building and running applications. It consists of the Common Language Runtime (CLR), which executes code, and the Framework Class Library, which provides ready-made functionality.
2. What are the main components of the .NET Framework?
The CLR, the Framework Class Library (including the Base Class Library), the Common Type System, the Common Language Specification, and application models such as ASP.NET, Windows Forms, WPF, WCF and ADO.NET.
3. How does language interoperability work in .NET?
All .NET languages compile to the same Intermediate Language and follow the Common Type System, so a class written in one language can be used, and even inherited, from another.
4. What is the latest version of the .NET Framework?
.NET Framework 4.8.1, released in 2022. It is the final version; new development happens in modern .NET.
Summary
- The .NET Framework is Microsoft's Windows platform for building and running applications.
- It consists of the CLR (the runtime) and a large class library.
- Code is compiled to IL, then turned into native code by the CLR's JIT compiler.
- It provides language interoperability, automatic memory management and easy deployment.
- Versions run from 1.0 (2002) to 4.8.1 (2022), the final version.