You are on page 1of 12


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.

NET Framework provides the following services:     Tools for developing software applications , run-time environments for software application to execute, server infrastructure, value added intelligent software which helps developers to do less coding and work efficiently,

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

The .NET Framework is designed to fulfill the following objectives:       A consistent object-oriented programming environment, where object code can be stored and executed locally, executed locally but Internet-distributed, or executed remotely. A code-execution environment that minimizes software deployment and versioning conflicts. A code-execution environment that guarantees safe execution of code, including code created by an unknown or semi-trusted third party. A code-execution environment that eliminates the performance problems of scripted or interpreted environments. Developers can experience consistency across widely varying types of applications, such as Windows-based applications and Web-based applications. Build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.

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

This we are going to understand using this article. and remoting.NET Framework. CLR act as an agent that manages code at execution time. The class library.NET Framework.NET Framework class library facilitates types (CTS) that are common to all .The .NET Framework The . The European Computer Manufacturers Association (ECMA) standard has defines the Common Language Specification (CLS). is a integral component of the . VJ#. and provide thread support.NET Framework Architecture has languages at the top such as VB . developers can develop (using any of above languages) applications such as Windows Forms. Windows Services and XML Web Services. consists of objectoriented 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. thread management. which compiles the IL code into native code. and executes and manage the code to enforce security and type safety. while also enforcing strict type safety and facilitates with code accuracy that ensure security and robustness. ASP. The common language runtime consists of (class loader) that load the IL code of a program into the runtime. NET Web Forms and Windows Services the newly invented XML Web services. The code written in a CLS should be . . Bottom two layers consist of .NET languages.NET C#. Code that targets the CLR is known as managed code. Understanding the Role of .NET Framework class library and Common Language Runtime. while code that does not target the CLR is known as unmanaged code.NET. providing core services such as memory management.NET Frameworkclass library. this enforces that software development languages should be interoperable between them. VC++ . The common language runtime is the foundation of the .NET Framework has two main components: the common language runtime (CLR) and the . The concept of code management is a fundamental principle of the CLR. Web Form.

NET Framework provides the infrastructure and services. called Microsoft Intermediate Language (MSIL). Common Language Infrastructure (CLI). values. object types. Figure 1. The CLI specifications. The CLI provides a common type system (CTS) and services such as type safety.   The CLR includes the CLI. Type safety. Where . The language compilers generate an Intermediate Language code.NETFramework supports Languages like Microsoft Visual Basic . This helps developers to develop applications in different languages. defines the specifications for the infrastructure that the IL code needs for execution. Microsoft Visual C#.NET Framework. Common type system. and Microsoft Visual J# .NET Applications.NET. managed code execution and side by side execution. The CLR also provides the execution environment for . The ECMA standard.compliant with the code written in another CLS-compliant language.NET languages share CTS mean all the types used in applications shares the same types defined under CLI.  Provides the data types. . This ensures interoperability between CLScompliant languages. Because the code supported by CLS-compliant language should be compiled into an intermediate language (IL) code. These include: Common language runtime. ECMA Standards under Microsoft . The .NET. Microsoft Visual C++ . The CLR engine executes the IL code. which makes programs written in the .NET. Microsoft .NET languages interoperable across languages.

NET Assembly Figure 2 Side-by-side Execution. .NET Framework Runtime executes multiple version of assembly and solves the major problem of legacy development environment. .NET Framework manages the state of the object while executing the . By this. Assemblies consist of IL Code and Metadata.NET Framework allows different version of the same application to run on the same machine by using assemblies of different versions.   . compile the IL code into native code. Side-by-side execution.NET Framework requires each value or object has a type and which reference to the value or object type. .NET Framework performs operations on the values or objects for which .   . Managed code execution. Understanding . Where metadata determines the application dependencies. That is the �DLL HELL�.NET Framework automatically allocates memory and provides garbage collation mechanism to de-allocate memory. execute the code .NET Applications.NET Framework CLR The common language runtime facilitates the followings: Run-time environment and  CLR Compiles application into the runtime.

Thread support. which allows . which provides multithreading support to applications. which provides the classes (types) that the applications need at run time.       Memory management. which loads classes into CLR. COM marshaler. Debug engine. which enforces strict type checking. Code manager. which provides a mechanism to handle the run-time exceptions handling.Run-time services. this enforces security restrictions as code level security folder level and machine level security using tools provided by Microsoft . which allows developer to debug different types of applications.NET Framework CLR            Class loader. this performs automatic memory management. Base class library support.NET applications to exchange data with COM applications.NET and using . Type checker. Enforces Security. Type safety. Exception Management. Memory allocation and Garbage collector. Thread support Debugging support Understanding Architecture of . Security engine. . this converts MSIL code into native code. Exception manager.NET Framework setting under control panel. this manages the code during execution. MSIL to native code compiles.

Before the execution of PE file it passes the code to the native code compiler for compilation. 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. Code Security based on Trust (granted permission to execute code. Machine level) These features are intrinsic to the managed code that runs on the common language runtime. Control the flow of execution. Code level. Folder level. 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. . Handles exceptions.independent code and instructions which is platform independent. MSIL code can be compiling into CPU specific instructions before executing. Manages interoperability with unmanaged code. MSIL consists of the followings:     Instructions that enables to perform arithmetic and logical operations Access memory directly.NET Framework. An assembly consists of portable executable file. o Allocation of Memory o De-Allocation of Memory (garbage collation) Thread execution support. for which the CLR requires information about the code which is nothing but metadata. Code execution. and COM marshaling A structured exception handling mechanism. 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 . IL to native code compilation is done by JIT compiler. Code safety verification. The language compiler compiles the source code into the MSIL code which consists of CPU.Features of the Common Language Runtime The CLR has the following Features       Manages memory. o MSIL to Native Code. Compilation. Future of CLR    Managed multithreading support and monitor the threads. For different CPU architecture and compilers for the IL code in to the native instructions. Application domain contains one or more threads to execute.

Debug engine supports debugging at runtime. IL to native compiler compiles the MSIL code to the Native code which is machine independent Garbage collector supports the Memory management and supports Clearing unused memory at runtime. Exception management supports handling Errors at runtime using try catch finally blocks. Code manger manages the Managed code at languages to support basic functionality COM Marshaler supports Marshaling of data between COM objects. Class loader lodes the classes at runtime 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. Security engine enforces security rules at runtime. Architecture of CLR           Base class library support supports all the base classes used for . memory management and garbage collection. The infrastructure and managed execution process. . Type checker checks for Type safe checks at runtime.

Handling exceptions. The JIT compiler compiles the method to before its execution of the entry point method. The code is controlled by CLR at run time. Managed code Execution Managed code execution is known as the process executed by the CLR which is as follows:        CLR loads the MSIL & refers metadata. The type checker also makes sure that only valid operations are performed on the code other wise the exception will be thrown. Enforcing security.    To control and access the system recourses like hard disk To control and access the network connections To control and access the other hard ware resources. Managed Execution Process . Ensuring type safety. CLR class loader lodes MSIL code and metadata are loaded into memory. The code manager places the objects in memory and controls the execution of the code.JIT Execution process. the code manager calls the entry point method which is WinMain or DLLMain method. The garbage collector performs periodic checks on the managed heap to identify the objects which is not in use for the application. CLR executes the Native code. CLR enforces security in following manner. and the references of objects and values has its valid type. At the time of program execution the type checker ensures that all objects and values. CLR provides automatic memory management. Managed execution also performs JIT compilations.

Roots point to the storage location on the managed heap. the new operator checks whether the memory required by the object is available on the heap. Managed data can be accessible form managed code but managed code can be accessible from managed and unmanaged data. Managed data is allocated and released from memory automatically by garbage collection. the garbage collector allocates memory to the object on the managed heap. 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. finding a large memory block to accommodate the You can access objects in managed memory faster than objects in unmanaged memory because in managed memory allocation. An application's roots consist of global and static object pointers. Therefore. local variables. When the next object is created. the pointers to memory are maintained in linked-list data structures. This information is stored in MSIL code in the form of metadata inside the PE file. In unmanaged memory. When an application uses the new operator to create an object. Each root either refers to an object on the managed heap or is set to null. Allocating memory to the objects in a managed heap takes less time than allocating unmanaged memory. This reserved address space is called a managed heap. When the garbage collector starts running. Every application has a set of roots. Releasing Memory The garbage collector periodically releases memory from the objects that are no longer required by the application. The process of automatic memory management involves the following tasks: Allocating memory When a process is initialized.NETFramework. the runtime reserves a contiguous address space without allocating any storage space for it. The JIT compiler and the run-time maintain the list of the application roots. objects are created contiguously in the managed address space. Mata data information will describe the types that the code contains. it identifies the objects that have corresponding references in the application root list and marks them . and reference object parameters on a thread stack. it considers all the objects on the managed heap as garbage. The garbage collector navigates through the application root list.Managed code is self-explanatory code which gives information to CLR for multiple runtime services in . The managed heap keeps a pointer at the location where the next object will be located. allocating memory requires navigating through the linked list. The garbage collector uses this list to create a graph of objects on the managed heap that are reachable from the root list.

The Finalize method ensures that even if the client does not call the Dispose method explicitly. Implementing Finalizers The finalization process allows an object to perform cleanup tasks automatically before garbage collection starts.Al. The garbage collector first collects the unreachable objects in generation 0. The garbage collector performs the memory copy function to compress the objects in the managed heap. We need to explicitly call the Dispose method after you finish working with the object. The garbage collector uses a highly optimized mechanism to perform garbage collection. The garbage collector updates the pointers in the application root list so that the application roots correctly point to the objects to which they were pointing earlier. or The Finalize method can call the Dispose method during the finalization process. 1. Generation 0 contains recently created objects. The Dispose method of an object should release all its resources in addition to the resources owned by its parent object by calling the Dispose method of the parent object. The garbage collector performs a collection process to free the memory occupied by the garbage objects. The Dispose and Finalizemethods are called finalizers. Finalizers are the methods that contain the cleanup code that is executed before the object is garbage collected. After the garbage collector identifies the object as garbage during garbage collection. . We can execute the Dispose method in two ways. The garbage collector manages memory for all managed objects created by the application. The garbage collector searches for unreachable objects in generations 1 and 2 only when the memory released by the collection process of generation 0 objects is insufficient to create the new object. The process of executing cleanup code is called finalization. It divides the objects on the managed heap into three generations: 0. o o The user of the class can call the Dispose method on the object that is being disposed. . the garbage collector compacts memory and promotes the reachable objects to generation 1. the resources used by the object are released from memory when the object is garbage collected. Next. The garbage collector also considers such objects as reachable objects. The objects that survive the collection process are promoted to higher generations. The garbage collection can explicitly release these system resources by providing the cleanup code in the Dispose method of the object. it calls the Finalize method on the object before releasing memory.NET Framework Tools Assembly Linker .as reachable.exe Tool Al tool can create an assembly or resource file with the manifest in a separate file out of modules. The garbage collector considers all unreachable objects on the managed heap as garbage. and 2.

License This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves..policies.NET Framework. machine level-policies.NET languages into a single application. This tool also creates code group policies at user level.Syntax: al [source] [options] This tool allows us to create multi-file assembly outside .exe Tool Ildasm tool is used to view PE file contains that is nothing but the MSIL code as a parameter and creates the text file that consists of managed code.exe Tool When we compile managed code. Syntax: caspol [options] . Etc. the code is converted into MSIL code. Code Access Security Policy Tool .exe Tool Caspol is nothing but Code Access Security Policy tool.NET Framework Configuration Tool .msc With this tool we can manage and configure assemblies in to the global assembly cache. this is CPU independent language which is converted to native code. The resulting executable file is performance optimized. machine-policy. and enterprisepolicy levels. A multi-file assembly is useful to combine modules developed under different . where the Ilasm tool does not create intermediate object file Syntax: Ilasm [source] filename [options] We can specify multiple source files to produce a single PE file. We can use Ilasm tool to generate a portable executable (PE) file from the MSIL code. IL Disassembler ..Mscorcfg.Ilasm. And also manage the code access security along with remoting services. If in doubt please contact the author via the discussion board below.Caspol. which allows us to grant and modify permissions granted to code groups at the user-policy. and enterprise level policies to assign and remove the permissions on assemblies developed within .NET.Ildasm. A list of licenses authors might use can be found here About the Author . IL Assembler .