Components Of .NET

.NET Introduction

.NET is not a programming language but it is a tool which provide an environment to write the code and run the applications. .NET support 63 programming languages in which 11 languages  developed by Microsoft and 52 programming languages developed by another organization.

The components of .NET  are CLR, Garbage Collector, JIT Compiler and base class library,

.NET Introduction
CLR (Common Language Runtime)

CLR is responsible for providing common syntax, automatic memory management and common data type. Also the responsibility of CLR is generating native code from MSIL Code.

CLS (Common Language Specification)

As we know that .NET support 63 programming language and also we know that each and every language has their own syntax for writing code and one language does not support syntax of another language. That means .NET has features of common syntax which is supported by all 63 programming language.

CTS (Common Type System)

As we know that .NET support 63 programming languages and also we know that each and every language has their own data type system and One language does not support data type of another language. That means .NET has features of Common Data type which is supported by all 63 programming languages.

Example

There is integer data type in C# .NET,

  1. int i = 123;  
There is Integer data type in J# .NET

Dim I As Integer

As we are looking both the languages has their own data type system. But these languages will support common data type of .NET which is:

Int 32

Garbage Collector

Garbage Collector is responsible for automatic memory management of objects. Also the responsibility of garbage collector is removing the object from memory which has no use. In Garbage Collector Memory divided in 3 generations and these generations are Generation 0, Generation 1 and Generation 2.

When new object creates it gets stored in Generation 0 and the process gets repeated till generation 0 is full. When Generation 0 size gets full then there 2 processes will be performed. First Process is marking the object which is not reachable for long time. And in Second process object will remove from memory which has marked early and remaining object will get transferred to Generation 1. This process will repeat also for Generation 2. There are 3 methods for removing object from Memory. These methods are (1) Dispose () (2) Finalize () (3) gc.Collect ().

 

  • Dispose Method: Dispose method is used to remove the object from memory which has no reference this method get call by User.
  • Finalize Method: Finalize method is used to clean up the object from memory. This method get call by System.
  • Gc.Collect Method: This method is used for removing the object from memory forcefully.

JIT Compiler: JIT Compiler is responsible for compiling the MSIL Code and generate Native Code. There are the following 3 types of JIT compiler,

  • Normol Jitter: Normal jitter is Default jitter which compile the code line by line and it store the cache of compiled code.
  • Echono Jitter: Echono jitter compile the selected line of code and it does not contain the cache of compiled code.
  • Pre Jitter: Pre Jitter Compile the code from top to button and also it store the cache of compiled code.

Why we use ngen.exe

Ngen.exe is a tool which is used to compile the MSIL code and generate native code. We use ngen.exe tool because it store all the compiled code in separate disk which is known as image generation files. The code compiled by ngen.exe can be reused but JIT compiler does not store compiled data.

Code Compilation in .NET

.NET support 63 programming language and each and every language has their own compiler. Language compiler the source code and generate MSIL (Microsoft Intermediate Language) then MSIL code get transferred to CLR and JIT compiler compile this code and generate native code.

Code Compilation in .NET

In .NET there are 2 phases of compilation of code. In first phase source code gets  compiled by source code language compiler and generate IL code and in second phase IL code gets compiled and generate native code. In this 1st Phase is slower than 2nd Phase. Code compilation in .NET is graphically represented above.

Up Next
    Ebook Download
    View all
    Learn
    View all