Components of .NET Framework
Common Language Runtime
CLR Provides an abstraction layer over the operating system.
Base Class Libraries:
Pre-built code for common low-level programming tasks.
- .NET includes the BCL in order to encapsulate a large number of common functions, such as file reading and writing, graphic rendering, database interaction, and XML document manipulation.
- Base Class Library provides all the functionality associated with traditional class libraries
Framework Class Library:
- Framework Class Library (FCL) includes a huge collection of reusable classes , interfaces, and value types that expedite and optimize the development process and provide access to system functionality.
- Framework class library (FCL) is organized in a hierarchical tree structure and it is divided into Namespaces.
Goal:
FCL is the portable operating system
CLR – Common Language Runtime
The Common Language Runtime (CLR) is an Execution Environment. It works as a layer between Operating Systems and the applications written in .Net languages that conform to the Common Language Specification (CLS).
The main functions of Common Language Runtime are
- CLR is the heart of .NET Framework.
- CLR is the execution engine of the .NET Framework.
- All .NET programs execute under the supervision of the CLR.
- Manages memory, code execution, code safety verification, compilation and other system services.
- The CLR supplies managed code with services such as cross-language integration, code access security, object lifetime management, and debugging and profiling support.
CLR ARCHITECTURE
CLR has two Major Subsets – CTS and CLS.
CTS – Common Type System
The Common Type System defines how data types are declared, used, and managed in the runtime, and is also an important part of the runtime‟s support for the Cross- Language Integration.
The common type system performs the following functions:
- Establishes a framework that enables cross-language integration, type safety, and high performance code execution.
- Defines rules that languages must follow, which helps ensure that objects written in different languages can interact with each other.
CLS – Common Language Specification
- CLS is a set of language rules that defines language standards for a .NET language and types declared in it.
- The CLS rules define a subset of the Common Type System
- Defines the minimum set of features that all .NET languages that target the CLR must support.
CLR EXECUTION MODEL
MSIL – (Microsoft Intermediate Language)
MSIL stands for Microsoft Intermediate Language. We can call it as an Intermediate Language (IL) or Common Intermediate Language (CIL). During the compile time, the compiler converts the source code into Microsoft Intermediate Language (MSIL). MSIL is a CPU-independent set of instructions that can be efficiently converted to the native code. During the runtime the Common Language Runtime (CLR)’s Just InTime (JIT) compiler converts the Microsoft Intermediate Language (MSIL) code into native code to the Operating System.
Just in Time (JIT)
It converts the MSIL code into native code (Machine Code). The .NET languages, which conform to the Common Language Specification (CLS), use their corresponding runtime to run the application on different Operating Systems. During the code execution, the Managed Code is compiled only when it is needed.
Types of JIT:
There are 3 Types of JIT
1. Pre-JIT :- Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.
2. Econo-JIT : – Econo-JIT compiles only those methods that are called at runtime. However, these complied methods are removed when they are not required.
3. Normal-JIT : – Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the complied code from cache is used for execution.