Introduction

In this article we are going to look at Microsoft .NET Framework. This is the newly established software development environment which helps developers to develop applications quickly and gives optimum, efficient, scalable, performance oriented applications in different languages like Visual Basic .NET, C#, ASP .NET, and Jscript .NET etc...

Overview of the .NET Framework

The .NET Framework is a new computing platform that simplifies application development in the highly distributed environment of the Internet.

Services
NET Framework provides the following services:

The .Net Framework will enable developers to develop applications for various devices and platforms like windows application web applications windows services and web services.

Objectives
The .NET Framework is designed to fulfill the following objectives:

Understanding the .NET Framework Architecture
The .NET Framework has two components: the .NET Framework class library and the common language runtime.

The .NET Framework class library facilitates types (CTS) that are common to all .NET languages.

The common language runtime consists of (class loader) that load the IL code of a program into the runtime, which compiles the IL code into native code, and executes and manage the code to enforce security and type safety, and provide thread support.

WhitePapers_DotNetFramework1.jpg

.NET Framework Architecture has languages at the top such as VB .NET C#, VJ#, VC++ .NET; developers can develop (using any of above languages) applications such as Windows Forms, Web Form, Windows Services and XML Web Services. Bottom two layers consist of .NET Framework class library and Common Language Runtime. This we are going to understand using this article.

Understanding the Roll of .NET Framework
The .NET Framework has two main components: the common language runtime (CLR) and the .NET Framework class library. The common language runtime is the foundation of the .NET Framework. CLR act as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and facilitates with code accuracy that ensure security and robustness. The concept of code management is a fundamental principle of the CLR. Code that targets the CLR is known as managed code, while code that does not target the CLR is known as unmanaged code.

The class library, is a integral component of the .NET Framework, consists of object-oriented collection of reusable classes (types) that we can use to develop applications ranging from traditional command-line or any graphical user interface (GUI) applications such as Windows Forms, ASP. NET Web Forms and Windows Services the newly invented XML Web services.

The European Computer Manufacturers Association (ECMA) standard has defines the Common Language Specification (CLS); this enforces that software development languages should be interoperable between them. The code written in a CLS should be compliant with the code written in another CLS-compliant language. Because the code supported by CLS-compliant language should be compiled into an intermediate language (IL) code. The CLR engine executes the IL code. This ensures interoperability between CLS-compliant languages. Microsoft .NET Framework supports Languages like Microsoft Visual Basic .NET, Microsoft Visual C#, Microsoft Visual C++ .NET, and Microsoft Visual J# .NET.

The language compilers generate an Intermediate Language code, called Microsoft Intermediate Language (MSIL), which makes programs written in the .NET languages interoperable across languages.

The ECMA standard, Common Language Infrastructure (CLI), defines the specifications for the infrastructure that the IL code needs for execution. The CLI provides a common type system (CTS) and services such as type safety, managed code execution and side by side execution.

WhitePapers_DotNetFramework2.jpg

Figure 1. ECMA Standards under Microsoft .NET Framework.

The .NET Framework provides the infrastructure and services. The CLI specifications. These include:

.NET Assembly

WhitePapers_DotNetFramework3.jpg

Figure 2 Side-by-side Execution.

Understanding .NET Framework CLR
The common language runtime facilitates the followings:

Understanding Architecture of .NET Framework CLR

WhitePapers_DotNetFramework4.jpg

Features of the Common Language Runtime
The CLR has the following Fractures

Understanding CLR
To execute the program and gain all the benefits of managed execution environment we write code in a language which is supported by CLS that is .NET Framework. The language compiler compiles the source code into the MSIL code which consists of CPU- independent code and instructions which is platform independent. MSIL consists of the followings:

MSIL code can be compiling into CPU specific instructions before executing, for which the CLR requires information about the code which is nothing but metadata. Metadata describes the code and defines the types that the code contains as well referenced to other types which the code uses at run time.

An assembly consists of portable executable file. At the time of executing PE file the class loader loads the MSIL code and the metadata form the portable executable file into the run time memory.

Before the execution of PE file it passes the code to the native code compiler for compilation, IL to native code compilation is done by JIT compiler. For different CPU architecture and compilers for the IL code in to the native instructions.

Futures of CLR

Architecture of CLR

WhitePapers_DotNetFramework5.jpg

Understanding JIT compiler
JIT compiler compiles is the integral part of CLR. the MSIL code to Native code and executes the batch of code Just in time which will be cached and next time when the code gets executed from cache in stud of compiling again.

WhitePapers_DotNetFramework6.jpg

JIT Execution process
CLR class loader lodes MSIL code and metadata are loaded into memory; the code manager calls the entry point method which is WinMain or DLLMain method. The JIT compiler compiles the method to before its execution of the entry point method. The code manager places the objects in memory and controls the execution of the code. The garbage collector performs periodic checks on the managed heap to identify the objects which is not in use for the application.
At the time of program execution the type checker ensures that all objects and values, and the references of objects and values has its valid type. The type checker also makes sure that only valid operations are performed on the code other wise the exception will be thrown. The code is controlled by CLR at run time. CLR enforces security in following manner.

Managed code Execution
Managed code execution is known as the process executed by the CLR which is as follows:

Managed Execution Process

Memory Management
Automatic memory management means no need to write code to allocate memory when objects are created or to release memory when objects are not required the application.

The process of automatic memory management involves the following tasks:

Allocating memory

Releasing Memory

Implementing Finalizers

.NET Framework Tools

Assembly Linker
Al.exe Tool

IL Assembler
Ilasm.exe Tool

IL Disassembler
Ildasm.exe Tool

Code Access Security Policy Tool
Caspol.exe Tool

.NET Framework Configuration Tool
Mscorcfg.msc