.NET framework is a software framework which is designed and developed by Microsoft. It is a runtime execution environment that manages the apps targeting the .NET framework. NET Framework is a development platform that includes a Common Language Runtime (CLR), which manages the execution of code, and a Base Class Library (BCL),
which provides a rich library of classes to build applications from. Microsoft originally designed the this Framework to have the possibility of being cross-platform, but they put their implementation effort into making it work best with Windows.
.NET Framework Architecture
Main Component of .NET Framework
Common Language Runtime (CLR)
CLR is the basic and Virtual Machine component of the .NET Framework. It is the run-time environment in the .NET Framework that runs the codes and helps in making the development process easier by providing the various services. Basically, it is responsible for managing the execution of .NET programs regardless of any .NET programming language. Internally, CLR implements the VES(Virtual Execution System) which is defined in the Microsoft’s implementation of the CLI(Common Language Infrastructure).
- Managed Code: The MSIL code which is managed by the CLR is known as the Managed Code. For managed code CLR provides three .NET facilities.
- Unmanaged Code: Before .NET development the programming language like .COM Components & Win32 API do not generate the MSIL code. So these are not managed by CLR rather managed by Operating System.
Benefits of CLR:
- It improves the performance by providing a rich interact between programs at run time.
- Enhance portability by removing the need of recompiling a program on any operating system that supports it.
- Security also increases as it analyzes the MSIL instructions whether they are safe or unsafe. Also, the use of delegates in place of function pointers enhance the type safety and security.
- Support automatic memory management with the help of Garbage Collector.
- Provides cross-language integration because CTS inside CLR provides a common standard that activates the different languages to extend and share each other’s libraries.
- Provides support to use the components that developed in other .NET programming languages.
- Provide language, platform, and architecture independence.
- It allows easy creation of scalable and multithreaded applications, as the developer has no need to think about the memory management and security issues.
Common Language Interpreter
This is the final layer in .NET which would be used to run a .NET program developed in any language. So, the subsequent compiler will send the program to the CLI layer to run the .NET application
Framework Class Library (FCL)
It is the collection of reusable object oriented class libraries and methods etc that can be integrated with CLR (It is also known as assemblies). It is just like the header files in C/C++ and packages in Java. Installing .NET framework basically is the installation of CLR and FCL into the system.
Common Type System (CTS)
Every programming language has its own data type system, so CTS is responsible for understanding all the data type systems of .NET programming languages and converting them into CLR understandable format which will be a common format.
There are 2 Types of CTS that every .NET programming language have :
- Value Types: Value Types will store the value directly into the memory location. These types work with stack mechanism only. CLR allows memory for these at Compile Time.
- Reference Types: Reference Types will contain a memory address of value because the reference types won’t store the variable value directly in memory. These types work with Heap mechanism. CLR allots memory for these at Runtime.
It is used to provide the Automatic Memory Management feature. If there was no garbage collector, programmers would have to write the memory management codes which will be a kind of overhead on programmers.
Just In Time (JIT) Compiler
It is responsible for converting the CIL(Common Intermediate Language) into machine code or native code using the Common Language Runtime environment.
.NET Framework Design Principles
.NET Framework was designed with certain principles in mind, which took into account knowledge and experience of past decades of software development.
- Interoperability. Computer systems often require interaction between new and old applications and .NET Framework provides means to use functionality implemented in newer and older programs that execute outside .NET environment.
- Language independence. .NET Framework introduced a Common Type System (CTS) that defines all possible data types and programming constructs supported by CLR and how they interact with each. Because of this feature, .NET Framework supports the exchange of types and object instances between dynamic libraries written using different .NET compatible languages.
- Portability. While Microsoft didn’t develop, .NET Framework itself to be cross-platform, open specification of Common Language Infrastructure (CLI) made it possible to implement it on different platforms.
- Security. Security was one of the main concerns in previous generation of software development platforms and .NET Framework has introduced its own security mechanism.
- Memory management. CLR frees the developer from the burden of memory management; it handles memory with such tool as Garbage Collector by detecting when memory can be safely freed.
- Performance. While smart memory management introduced some performance overhead, Microsoft made significant effort to bring performance of its framework close to performance of applications written with “native” programming code.
- .NET Framework is a large software framework and it simplifies software development.
- It has advanced and sophisticated architecture, which took into account knowledge and experience of past of software development.
- It has a lot of benefits and components for modern software development.