Explain .Net Architecture.
.Net is a
generic software development framework that allows to build and run different types of software on top of it.Net framework provides all the services that different type of application needs to run. For example .Net framework provides the ability to applications to communicate to the database, communicate to networking devices, working with XML files, date times and all core functionalities that an application needs.
Image Source: MSDN
.Net framework consists of 2 major components
Common language runtime (CLR)- Responsible for execution of .net applications
Framework class library (FCL)- A very large class library, provides all the services that an application needs to run and very helpful in day to day life.
In rest of the subsequent questions will describe each and every component in detail, depicted in above diagram.
What are the major components of .Net framework?
.Net framework is a generic software development framework, on top of which we can develop different types of applications such as
.Net framework comes with the following components
Image Source: Wikipedia
Each component is explained in subsequent questions.
What is CLR?
CLR stands for
common language runtime. CLR provides the
execution environment for .Net applications. CLR is virtual machine similar to
JVM (java virtual machine) in Java, which virtualizes execution environment. CLR is available with the almost every version of windows (Windows XP, Windows 7, Windows 8, Windows phone, windows server e.t.c.) by default.
What is FCL?
FCL stands for
Framework class library. Framework class library contains thousands of classes used to build applications and provides all the basic functionalities and services that application needs such as Communication to the database, communication to services, text parsing, working with files e.t.c.
What is BCL/ CL in .Net?
BCL stands for
Base class library also known as
Class library (CL). BCL is a
subset of Framework class library (FCL). Class library is the collection of reusable types that are closely integrated with CLR. Base Class library provides classes and types that are helpful in performing day to day operation e.g. dealing with string and primitive types, database connection, IO operations.
Namespace included in Base Class library are as following
||Provides primitive data types, console, array etc.|
||Provide classes to work with collection e.g. List, stack, queue, dictionary|
||Used for reading and writing program configuration data|
||Provide classes to work with Data, ADO.Net|
||Provides tracing, logging, performance counters, etc. functionality|
||Provide classes to work with graphics|
||Provide classes to support globalization|
||Provides classes to work file files, IO stream.|
||Interface to LINQ providers and the execution of LINQ queries|
||Provide classes to work with network protocol e.g. SMTP, TCP|
||provide classes to read class/assembly information at runtime|
||Provide classes to work with multilingual resources.|
||provide classes to work with encryption, hashing etc.|
||Provide classes for text encoding, dealing with regular expression|
||Contains methods to manage the creation, synchronization and pooling of program threads|
||Classes to work with web application like ASP.Net, Web services and MVC|
||Provide classes to work with XML type|
What is MSIL?
MSIL stands for
Microsoft Intermediate language, also known as
Intermediate language (IL). When we compile source code written in any .Net language e.g. C#, VB, VC++, F# then compiler generates an intermediate code known as MSIL. Further CLR reads MSIL and translates it to native instructions that a computer hardware understands.
MSIL defines instructions for CLR.
What is Manifest?
Assembly manifest file stores assembly metadata information such as how the elements inside the assembly are related to each other. Assembly manifest file includes following information. An assembly manifest information can be stored in standalone in the
How to enforce garbage collection in .NET?
.Net framework provides Collect() method to enforce garbage collector to run. Below is the Syntax.
What is garbage collection?
manages allocation and release of memory for the application. When any application starts, it initializes objects. Common language runtime allocates memory from managed heap when a new object in being initialized. CLR keep initializing memory for all the applications. As the computer memory is limited so its garbage collectors job to free up some memory. Garbage collector's optimizing engine determines which is the best time to clean memory. Garbage collector frees up memory by removing the object that are not in use.
What is difference between
dispose () and
finalize () method in .net?
Dispose () and
finalize () methods are used to release memory held by unmanaged resources database connections, file IO operations, COM objects. The main difference in between two is that finalize () method is
called by garbage collector (GC) internally to free up memory while dispose () method is
called by user code explicitly.
To call dispose () method explicitly, class need to implement IDisposible interface.
It is best practice to implement dispose () method to free up memory as it will immediately free up memory as soon as the currently executing code block completes. Garbage collector does not call
finalize () method immediately, so it has some