.NET framework and its building blocks

What is Microsoft .NET
.NET is a collections of API and library of shared code which is accessible to developers to create new applications.
Key benefits of .NET
-          Interoperability with existing code.
-          Support for numerous programming language.
-          Common runtime engine shared across all .NET aware languages.
-          Language integration.
-          Comprehensive base class library

.Net Framework provides runtime environment called Common Language Runtime (CLR).It provides an environment to run all the .Net Programs. The code which runs under the CLR is called as Managed Code. Programmers need not to worry on managing the memory if the programs are running under the CLR as it provides memory management and thread management.

Programmatically, when our program needs memory, CLR allocates the memory for scope and de-allocates the memory if the scope is completed.

Language Compilers (e.g. C#, VB.Net, J#) will convert the Code/Program to Microsoft Intermediate Language (MSIL) intern this will be converted to Native Code by CLR. See the below Fig. 

There are currently over 15 language compilers being built by Microsoft and other companies also producing the code that will execute under CLR. 





Building blocks of .NET
Common language runtime (CLR)
.Net Framework provides runtime environment called Common Language Runtime (CLR).It provides an environment to run all the .Net Programs. The code which runs under the CLR is called as Managed Code. Programmers need not to worry on managing the memory if the programs are running under the CLR as it provides memory management and thread management.
Runtime environment is like sandbox server or virtual machines where applications could run. Just like JVM for Java.
CLR also provides other services such as Memory management, thread management and security.
Runtime environment is actually a way of abstracting the application from hardware on which application is running.

Common type system (CTS)
This stands for common type system which defines some rules need to be followed while using types i.e. declaring variables.
This is called CTS because all language have different datatype but these datatype are converted to common datatype.
For example: C# has int for numeric values but VB has Integer, but when code compiles both the datatypes are converted to Integer32.

Common Language specification (CLS)
This is a set of some basic language features that .NET languages needed to develop applications.
This has some rules and restriction which every .NET aware language needs to follow in order to use objects of one language into another language. Language which follows these rules is called CLS compliant language.
In simple word, CLS enables cross language integration.

For example:  one cannot use multiple inheritance in .NET framework because CLS does not allow this, however one can use multiple inheritance in C++.

Base class library
This is a huge collection of reusable code which can be used across many .NET aware languages. These reusable libraries are used in all language in same way.
These are grouped in a namespace.
System is the root of all the class libraries.
Different types of applications that can make use of BCL
-          Windows applications
-          Console applications
-          Web applications.
-          Windows services
-          XML document
-          Database applications




When an application is executed, its code is compiled in machine language and then executed.

Managed v/s unmanaged code
Code which directly targets .NET platform is called managed code. Binary unit that contains this managed code is called assembly.
Code that cannot be directly hosted by .NET runtime is called unmanaged code.
Common Intermediate language
Every .NET aware language compiler compiles source code into CIL. In another term, CIL sits above platform specific instruction set.
Every .NET aware language generates almost identical CIL.
This CIL is converted into machine language using JUST-IN-TIME compiler. (JITTER)
The .NET runtime environment has JUST IN TIME compiler for each CPU targeting the runtime.

For each CPU JITTER have different capabilities for example handheld devices works on low memory environment where desktop or mainframe are not memory restricted.
Metadata: this contains details of each method, class and variables used in assembly.
Manifest: information about assembly itself like version, created or modified date and any other assembly related information.

Comments