Overview Of .NET Framework

To work on ASP. NET and to understand the ASP. NET world, first we have to understand .NET Framework. It is a common question which is asked in interviews that "What is .NET Framework and the need of .NET Framework?"

As I know my friends and colleagues who is working as a web developer also face problems on .NET Framework's questions. So, today I decided to write about .NET framework.

.NET Framework

  1. .NET framework is a complete development and execution environment. That allows the developer to develop, run and deploy the following application.

    1. Console application.
    2. Windows application
    3. Web application
    4. Service oriented application (WCF)
    5. Web service
    6. Windows service
    7. WPF, WWF etc.

  2. .NET framework support the object oriented programming model for multiple language such as, C#, VB, vC++, J#, etc.

  3. It support the language interoperability. Interoperability implies that each language can use the code written in some other language.

  4. It provides a common set of tools and enables easy integration of module developed with one another.

  5. It also enables the developers to create shareable component to be used in distributed computing architecture.

Need of .NET Framework

.NET Framework was designed to fulfill the following goals.

  1. Interoperability
  2. Cross platform Support
  3. Language Independence
  4. Base class library.
  5. Easy development f. Security

Interoperability

.NET Framework supports interoperability between new application and existing application. It implies that the code written in one language can be used in some other language.

Cross Platform support

Each .NET compatible language, such as C#, VB, VC++ provides its own compiler to compile code to MSIL. After that, the common runtime engine compile MSIL code to native code with the help of Just In Time (JIT) compiler and then run the application.

Cross Platform

Language Independence

.NET framework provides the multiple language support by using feature known as common type system. That is built into common language runtime.

Base Class Library

The base class library provides the fundamental building block for any application you develop. These applications could be windows, web, console, or service oriented. The BCL mostly serves as the main point of interaction with the CLR.

Easy Deployment

.NET Framework makes the task of employment easier. In most cases, to install an application along with component on the target computer is easier.

Security

.NET Framework provides security model that allows you to authorize and authenticate the user.

Component of .NET Framework

The following are the main components of the .NET Framework.

  1. .NET Framework library
  2. CLR
  3. DLR (Dynamic Language Runtime
  4. Application Domain
  5. Runtime host
  6. CTS ( Common Type System)
  7. Metadata
  8. Cross Language Interoperability
  9. Security
  10. Side by side execution
  11. Profiling etc.

Above all components discussed separately in next topic.

MSIL (Microsoft Intermediate Language) OR Intermediate Language( IL)

IL stands for Intermediate Language. It is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language ). All the .NET language such as C#, J#,VB uses there own compiler. The compiler compile the code into IL and after thaT common runtime engine convert the IL code into native code with the help of JIT compiler.

OR

MSIL: .NET is shipped with compiler of all programming language to develop program. There are separate compiler for the VB, C#, VC++, etc. All compilers produce an intermediate code after compiling source code. The intermediate code is common for all language and it is understandable into .NET environment. This intermediate code is known as IL or MSIL.

Assembly Manifest

Assembly manifest stores the assembly metadata. It contains all the metadata needed to do the following things:

  1. Version of assembly
  2. Security Identity
  3. Scope of assembly
  4. Resolve reference to resource of class

Assembly manifest contains PE file either .exe or .dll

Common Type System

CTS is a component of CLR (Common Language Runtime) through which .NET framework provide support for multiple language. Because it contains a type system, that is common across all the languages. Two common type system language do not require type conversion when calling the code written in another language. CTS provide a base set of data type for all languages supported by .NET framework. This means that the size of integer and long variable is same across all language.

Managed and Unmanaged code

  • Managed Code: Managed code is the code that executed directly by CLR instead of operating system. The language compiler compile the managed code to IL or MSIL. This code does not depend on the machine configuration and can be executed on different machine. Managed code process are as follows:

    Choose Language Compiler --> Compile to MSIL, MSIL to Native Code, then Execute the code

  • Unmanaged Code: Unmanaged code is the code that is executed directly by the operating system outside the CLR environment. It is directly compiled to native machine code which depends on the machine configuration. In unmanaged code, the allocation of memory , Type safety and security is required to be taken care of by the developer. If unmanaged code is not properly handled it may result in memory leak.

Assembly in .NET framework

Every software has an executable file (.exe) apart from the .exe file, there are some dynamic link library (.dll) and Library file (.lib) that contains the compiled code of some commonly used function. These files are shipped along with the software. Any software package includes an executed file along with some DLL and LIB file that are necessary to run the application. In .NET runtime terms, the process of packing is called assembly. An assembly contains MSIL, Metadata file are required to execute a .NET program successfully. There are two types of assembly,

  1. Private Assembly
  2. Public assembly

Global Assembly Catch (GAC )

While using shared assembly, to avoid assembly being overwritten by the different or same assembly . Shared assembly are placed in a special directory in the file system are known as global assembly catch.

Or

GAC is a central repository (cache) in a system in which assemblies are registered to share among various applications that execute on local or remote machines. .NET Framework provides the GAC tool (gacutil.exe utility), which is used to view and change the content of GAC of a system. Adding new assemblies to GAC and removing assemblies from GAC are some of the tasks that can be performed using the gacutil.exe utility. GAC can contain multiple versions of the same .NET assembly. CLR checks GAC for a requested assembly before using information of configuration files.

Component and services of CLR

There are several component of CLR, which are as follows:

  1. CTS
  2. MSIL
  3. Execution Support Function
  4. Security
  5. Garbage collection
  6. Class loader
  7. Memory layout

Services of CLR

  1. Loading and execution of program.
  2. Memory Isolation for application.
  3. Verification of type safety.
  4. Compilation of MSIL to native code.
  5. Providing Metadata.
  6. Interoperability with other system.
  7. Managing exception and error.
  8. Debugging and profiling.

Garbage collection

Garbage collection prevent memory leaks during execution of programs. It is a low priority process that manages the allocation and deallocation of memory in your application. It checks for unreferenced variable and objects. If GC find any object that is no longer used by application, it frees up the memory that object.

GC has changed a bit in .NET framework 4.0. It contains the following overload method,

  1. GC.collect ()
  2. GC.collect (int, GC collection method)

Generation of garbage collection

  1. Generation 0: When an object is initialized.
  2. Generation 1: The object under the GC process.
  3. Generation 2: Whenever new object is created and added to memory. It adds generation 0 and generation 1.

Namespace in .NET framework

Namespace has two basic functionalities:

  1. It is a logically group type.
  2. In object oriented world many times it is possible that programmer will use the same class name by qualifying namespace with class name, this collision is able to remove.

Difference between Assembly and Namespace

  1. An assembly is a physical grouping of logical unit while namespace is logical group of class.
  2. A namespace can span multiple assembly.
  3. It is a collection of names wherein each name is unique. While assembly is an output unit it contains a unit of development and deployment.

Difference between private and shared assembly

Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

Up Next
    Ebook Download
    View all
    Learn
    View all