NET Framework
NET Framework
It is used to develop applications for web, Windows, phone. Moreover, it provides a broad range of
functionalities and support.
This framework contains a large number of class libraries known as Framework Class Library (FCL). The
software programs written in .NET are executed in the execution environment, which is called CLR
(Common Language Runtime). These are the core and essential parts of the .NET framework.
This framework provides various services like memory management, networking, security, memory
management, and type-safety.
The .Net Framework supports more than 60 programming languages such as C#, F#, VB.NET, J#, VC++,
JScript.NET, APL, COBOL, Perl, Oberon, ML, Pascal, Eiffel, Smalltalk, Python, Cobra, ADA, etc.
Following is the .NET framework Stack that shows the modules and components of the Framework.
4. Other Modules (WCF, WPF, WF, Card Space, LINQ, Entity Framework, Parallel LINQ, Task Parallel
Library, etc.)
CLR (Common Language Runtime)
It is a program execution engine that loads and executes the program. It converts the program into
native code. It acts as an interface between the framework and operating system. It does exception
handling, memory management, and garbage collection. Moreover, it provides security, type-safety,
interoperability, and portablility. A list of CLR components are given below:
It is a standard library that is a collection of thousands of classes and used to build an application. The
BCL (Base Class Library) is the core of the FCL and provides basic functionalities.
WinForms
Windows Forms is a smart client technology for the .NET Framework, a set of managed libraries that
simplify common application tasks such as reading and writing to the file system.
ASP.NET
ASP.NET is a web framework designed and developed by Microsoft. It is used to develop websites, web
applications, and web services. It provides a fantastic integration of HTML, CSS, and JavaScript. It was
first released in January 2002.
ADO.NET
ADO.NET is a module of .Net Framework, which is used to establish a connection between application
and data sources. Data sources can be such as SQL Server and XML. ADO .NET consists of classes that can
be used to connect, retrieve, insert, and delete data.
Windows Presentation Foundation (WPF) is a graphical subsystem by Microsoft for rendering user
interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as
part of .NET Framework 3.0 in 2006. WPF uses DirectX.
WF (Workflow Foundation)
Windows Workflow Foundation (WF) is a Microsoft technology that provides an API, an in-process
workflow engine, and a rehostable designer to implement long-running processes as workflows
within .NET applications.
It is a query language, introduced in .NET 3.5 framework. It is used to make the query for data sources
with C# or Visual Basics programming languages.
Entity Framework
It is an ORM based open source framework which is used to work with a database using .NET objects. It
eliminates a lot of developers effort to handle the database. It is Microsoft's recommended technology
to deal with the database.
Parallel LINQ
Parallel LINQ or PLINQ is a parallel implementation of LINQ to objects. It combines the simplicity and
readability of LINQ and provides the power of parallel programming.
It can improve and provide fast speed to execute the LINQ query by using all available computer
capabilities.
Apart from the above features and libraries, .NET includes other APIs and Model to improve and
enhance the .NET framework.
In 2015, Task parallel and Task parallel libraries were added. In .NET 4.5, a task-based asynchronous
model was added.
.NET CLR is a runtime environment that manages and executes the code written in any .NET
programming language. CLR is the virtual machine component of the .NET framework. That language's
compiler compiles the source code of applications developed using .NET compliant languages into CLR's
intermediate language called MSIL, i.e., Microsoft intermediate language code. This code is platform-
independent. It is comparable to byte code in java. Metadata is also generated during compilation and
MSIL code and stored in a file known as the Manifest file. This metadata is generally about members and
types required by CLR to execute MSIL code. A just-in-time compiler component of CLR converts MSIL
code into native code of the machine. This code is platform-dependent. CLR manages memory, threads,
exceptions, code execution, code safety, verification, and compilation.
The following figure shows the conversion of source code into native code.
The above figure converts code into native code, which the CPU can execute.
o Garbage Collector
CTS provides guidelines for declaring, using, and managing data types at runtime. It offers cross-language
communication. For example, VB.NET has an integer data type, and C# has an int data type for managing
integers. After compilation, Int32 is used by both data types. So, CTS provides the data types using
managed code. A common type system helps in writing language-independent code.
1. Value Type: A value type stores the data in memory allocated on the stack or inline in a
structure. This category of Type holds the data directory. If one variable's value is copied to
another, both the variables store data independently. It can be of inbuilt-in types, user-defined,
or enumerations types. Built-in types are primitive data types like numeric, Boolean, char, and
date. Users in the source code create user-defined types. An enumeration refers to a set of
enumerated values represented by labels but stored as a numeric type.
2. Reference Type: A Reference type stores a reference to the value of a memory address and is
allocated on the heap. Heap memory is used for dynamic memory allocation. Reference Type
does not hold actual data directly but holds the address of data. Whenever a reference type
object is made, it copies the address and not actual data. Therefore two variables will refer to
the same data. If data of one Reference Type object is changed, the same is reflected for the
other object. Reference types can be self-describing types, pointer types, or interference types.
The self-describing types may be string, array, and class types that store metadata about
themselves.
Common Language Specification (CLS) contains a set of rules to be followed by all NET-supported
languages. The common rules make it easy to implement language integration and help in cross-
language inheritance and debugging. Each language supported by NET Framework has its own syntax
rules. But CLS ensures interoperability among applications developed using NET languages.
3. Garbage Collection:
Garbage Collector is a component of CLR that works as an automatic memory manager. It helps manage
memory by automatically allocating memory according to the requirement. It allocates heap memory to
objects. When objects are not in use, it reclaims the memory allocated to them for future use. It also
ensures the safety of objects by not allowing one object to use the content of another object.
5. Metadata:
A Metadata is a binary information about the program, either stored in a CLR Portable Executable file
(PE) along with MSIL code or in the memory. During the execution of MSIL, metadata is also loaded into
memory for proper interpretation of classes and related. Information used in code. So, metadata helps
implement code in a language-neutral manner or achieve language interoperability.
6. Assemblies:
An assembly is a fundamental unit of physical code grouping. It consists of the assembly manifest,
metadata, MSIL code, and a set of resources like image files. It is also considered a basic deployment
unit, version control, reuse, security permissions, etc.
o Handles Exceptions
o Provides type-safety
o Memory management
o Provides security
o Improved performance
o Language independent
o Platform independent
o Garbage collection
o Provides language features such as inheritance, interfaces, and overloading for object-oriented
programs.
The code that runs with CLR is called managed code, whereas the code outside the CLR is called
unmanaged code. The CLR also provides an Interoperability layer, which allows both the managed and
unmanaged codes to interoperate.
1. Managed code:
Any language that is written in the .NET framework is managed code. Managed code use CLR, which
looks after your applications by managing memory, handling security, allowing cross-language
debugging, etc. The process of managed code is shown in the figure:
2. Unmanaged code:
The code developed outside the .NET framework is known as unmanaged code. Applications that do not
run under the control of the CLR are said to be unmanaged. Certain languages such as C++ can be used
to write such applications, such as low-level access functions of the operating system. Background
compatibility with VB, ASP, and COM are examples of unmanaged code. This code is executed with the
help of wrapper classes. The unmanaged code process is shown below:
.NET CLR Versions
1.0 1.0
1.1 1.1
2.0 2.0
3.0 2.0
3.5 2.0
4 4
4.5 4
4.6 4
4.6 4
Thread Support
COM Marshaler
Security Engine
Debug Engine
It allows you to debug different kinds of applications.
Type Checker
It checks the types used in the application and verifies that they match the standards provided by the
CLR.
Code Manager
Garbage Collector
Exception Handler
ClassLoader
.NET Framework Class Library is the collection of classes, namespaces, interfaces and value types that
are used for .NET applications.
o Access to data
Namespaces Description
System.IO, System.DirectoryServices,
These are used to access, read and write files.
System.IO.IsolatedStorage
System.Web, System.WebCaching,
System.Web.UI, System.Web.UI.Design,
System.Web.UI.WebControls,
These are used to create ASP. NET Web
System.Web.UI.HtmlControls,
applications that run over the web.
System.Web.Configuration,
System.Web.Hosting, System.Web.Mail,
System.Web.SessionState
System.Web.Services,
System.Web.Services.Description, These are used to create XML Web services
System.Web.Services.Configuration, and components that can be published over
System.Web.Services.Discovery, the web.
System.Web.Services.Protocols
System.Security, System.Security.Permissions,
These are used for authentication,
System.Security.Policy, System.WebSecurity,
authorization, and encryption purpose.
System.Security.Cryptography
System.Xml, System.Xml.Schema,
These namespaces are used to create and
System.Xml.Serialization, System.Xml.XPath,
access XML files.
System.Xml.Xsl
.NET Base Class Library is the sub part of the Framework that provides library support to Common
Language Runtime to work properly. It includes the System namespace and core types of the .NET
framework.