0% found this document useful (0 votes)
37 views

Unit - 1 VP-1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Unit - 1 VP-1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Shriram Institute of Information Technology, Paniv

Unit – I
.NET Architecture

➢ Introduction to .Net Framework –


The .NET is a software framework which is designed and developed by Microsoft. The first version
of the .Net framework was 1.0 which came in the year 2002. It is used to develop window-based applications,
Web-based applications, console based application and Web services. There is a variety of programming
languages available on the .Net platform such as VB.Net and C# and more. The .Net is platform where multiple
technologies can work together. It is used to build applications for Windows, phone, web, etc.

Fig - .Net Framework

➢ Component of .Net Framework –


There are main four components of .net framework as bellow:-
1) Common Language Runtime (CLR)
2) Framework Class Library (FCL)
3) Common Language Specification (CLS)
4) Common Type System (CTS)

1) Common Language Runtime (CLR) -


Common Language Runtime is a execution engine of .Net framework. It is heart of .Net
framework and it is interface between application and operating system. CLR is system that manages the
loading and execution of our program. When we compile c# program, the output of compiler is not executable
code, instead it is a file that contain special type of pseudo code instruction called Microsoft Intermediate

Prof. Honrao Charushila Prakash (1 )


Shriram Institute of Information Technology, Paniv

language (MSIL). The function of CLR is to convert managed code (MSIL) into machine native code
(executable code) and then execute the program. It means .Net application is compiled into byte code format
known as MSIL. During execution the CLR (JIT) compiler (Just-In-Time compiler) converts byte code into
processor native code and executes the application. CLR are also provides the following services / function:-
1) Memory management or garbage collection.
2) Loading and Execution of Program.
3) Convert intermediate language code to machine native code.
4) Exception Handling.
5) Class Loader.
6) Interoperability of other language.
7) Security.

Common Language Runtime has a following block diagram that show the working of CLR.

Fig – Block Diagram of CLR

Prof. Honrao Charushila Prakash (2 )


Shriram Institute of Information Technology, Paniv

❖ Component of CLR –
There are following component of CLR –
1) Class Loader
2) Type Definition
3) COM marshaling
4) Debug manager
5) Exception manager
6) Code Manager
7) Security Engine
8) Thread Support
9) Garbage Collector
10) IL to Native Convertor (JIT)
11) BCL Support

2) Framework Class Library (FCL) –


The .Net framework has provided large class library for developing windows, web and
console application in .net. The FCL is a collection of large amount of classes and data types. This is also
called as Base Class Library and it is common for all types of applications. It is just like the header files in
C/C++ and packages in the java. It is common for all types of applications in .Net, i.e. the way you access the
Library Classes and Methods in VB.NET will be the same in C#, and it is common for all other languages in
.Net. In short, developers just need to import the BCL in their language code and use its predefined methods and
properties to implement common and complex functions like reading and writing to file, graphic rendering,
database interaction, and XML document manipulation. Classes have organized in a logical hierarchy called
‘namespace’. “Namespace is a way to group a collection classes and interface together”. This class library is
common to all languages in .NET.
E.g.: System is highest level namespace also called root namespace. All framework classes are inherited from
root class called Object. This object class defined in system namespace.
E.g. of namespace
System.Web, System.text, System.Collection.

3) Common Language Specification (CLS) -


An important goal of .Net framework is to support multiple languages, but all language is not
created equals. So it is important to agree upon a common subset, that all language will support. CLS defines a
set of rules for all compilers that plan to generate managed code for .Net application. CLS defines a set of rules

Prof. Honrao Charushila Prakash (3 )


Shriram Institute of Information Technology, Paniv

that enables interoperability on the .Net platform Common Language Specification (CLS) is a set of basic
language features that .Net Languages needed to develop Applications and Services , which are compatible with
the .Net Framework. It supports reusability; therefore improve the efficiency of development process. CLS is
subset of CTS.
Here, some examples of CLS rules-
1) Use of new keyword to instantiate a class.
2) Array index should be ‘0’ based.
3) Multiple inheritances should not be support by language.
4) Third parity language should be object oriented.

Fig – CTS Working

4) Common Type System (CTS) -


It describes set of data types that can be used in different .Net languages in common. Common
Type System (CTS) describes the data types that can be used by managed code. It is a collection of data types
provided by the framework that can be used for interoperability purpose. CTS deals with the data type. So here
we have several languages and each and every language has its own data type and one language data type
cannot be understandable by other languages but .NET Framework language can understand all the data types.
To implement CTS is converting the data type to a common data type,
Eg. When we declare an int type data type in C# and VB.Net then they are converted to int32. In other words,
now both will have a common data type that provides flexible communication between these two languages.

Prof. Honrao Charushila Prakash (4 )


Shriram Institute of Information Technology, Paniv

CTS support two general categories of type, which are derived from base type called
“System.Object”:
1) Value types:-
Value types directly contain their data, and instances of value types are either allocated on the
stack or allocated inline in a structure.
2) Reference types:-
Reference types store a reference to the value's memory address, and are allocated on the heap.
Reference types can be self-describing types, pointer types, or interface types. The type of a reference
type can be determined from values of self-describing types. Self-describing types are further split into
arrays and class types. The class types are user-defined classes, boxed value types, and delegates.

➢ Managed Code -
The Managed code is whose execution is managed by CLR. Managed code is written in the high
level language like C#, VB.Net etc. Managed code always implemented by managed runtime environment.
The managed runtime environment provides different types of services like garbage collection, type checking,
exception handling, bounds checking, etc. to code automatically without the interference of the programmer.
The application is written in the languages like Java, C#, VB.Net, etc. are always aimed at runtime
environment services to manage the execution and the code written in these types of languages are known as
managed code. In the case of .NET Framework, the compiler always compiles the manages code in the
intermediate language(MSIL) and then create an executable code then the Just In Time Compiler of CLR
compiles the intermediate language in the native code which is understandable to machine. The managed code
also provides platform independence because when the managed code compiled into the intermediate language,
then the JIT compiler compiles this intermediate language in the architecture specific instruction.

➢ Advantages of Managed Code –


1) It improves the security of the application like when you use runtime environment, it automatically
checks the memory buffers to guard against buffer overflow.
2) It implements the garbage collection automatically.
3) It also provides runtime type checking/dynamic type checking.
4) It also provides reference checking which means it checks whether the reference point to the valid
object or not and also check they are not duplicate.

Prof. Honrao Charushila Prakash (5 )


Shriram Institute of Information Technology, Paniv

➢ Intermediate Language –
Intermediate language (IL) is an object-oriented programming language designed to be used by compilers for
the .NET Framework before static or dynamic compilation to machine code. IL is a set of instructions that are
platform independent and are generated by the language-specific compiler from the source code. The IL is used
by the .NET Framework to generate machine-independent code as the output of compilation of the source code
written in any .NET programming language. IL is a stack-based assembly language that gets converted to byte
code during execution of a virtual machine. This term is also known as Microsoft intermediate language (MSIL)
or common intermediate language (CIL). MSIL includes instruction for loading, sorting, initializing and calling
methods or objects as well as instructions for arithmetic or logical operations, control flow, direct memory
access, exception handling or other operations.

➢ Garbage Collection –
C# and CLR work together to provide automatic memory management. We do not need to write
code to allocate or free the memory. The garbage collector (GC) manages the allocation and release of memory.
The garbage collector serves as an automatic memory manager. The CLR monitors memory usage and
automatically retrieves more when we need. It also frees memory automatically when it detect that it is no
longer being used. This is known as Garbage Collection. In an object oriented language including C# every time
object need to be allocated some memory space and require some resources like screen space, buffers and
hardware connection and so on. In many programming languages the release of previously allocated memory is
handled manually. E.g.- In C++, we use delete operator to free memory, that was allocated.
With Garbage Collector the user does not have to worry about tracking how much memory is in
use and when can it be free. Since, memory is finite; some sort of collection is required to free the memory.

Prof. Honrao Charushila Prakash (6 )


Shriram Institute of Information Technology, Paniv

Garbage collector manages the allocation and release of memory for automatically. This means automatic
memory management in .NET is done by Garbage Collector. Garbage Collector is the component of CLR.
When the garbage collector performs collection, it checks the objects in managed heap that are no longer being
used by the application and then reallocates that part of memory to some other objects.
Example -

****

Prof. Honrao Charushila Prakash (7 )

You might also like