[Link].
(Computer Science)
SEM-II
Course Code : 19ScCmpP206
Course Name : DOT NET
Presented By: Smita Achalkar
Modern College of Arts,Science and
Commerce ,Pune-5
Notes
Chapter 1
DOTNET Framework
Chapter 1
DOTNET Framework
Yesterday
Yesterday We We
hadhad learned-- the following points which are
discussed
mentioned:
Introduction of [Link]
Features of [Link]
Advantage of [Link]
IIS Server
Features of IIS
Working of IIS with [Link] Application
Working With IDE
Web Form/Web Page
Components of Web Form
Now we shall start the next Lecture ……….
Chapter 1
DOTNET Framework
Points to be covered in today’s Lecture
1.3Common Language Runtime
1.3.1Overview
1.3.2 Elements of .NET application
1.3.3Memory Management
1.3.4 Garbage Collector : Faster Memory allocation,
Optimizations
1.4 Common Language Integration
1.4.1 Common type system
1.4.2 Reflection API
1.5 User and Program Interface
Chapter 1
DOTNET
.Net Framework
Framework delivers runtime environment called Common Language
1.3Common
Runtime (CLR).Language Runtime
It offers an environment to run all the .Net Programs.
The code which runs below the CLR is called as Managed Code. Developers
not required on managing the memory if the programs are running below
the CLR as it delivers memory management and thread management.
Programmatically, when our program requires memory, CLR assigns the
memory for scope and de-allocates the memory if the scope is
accomplished. Language Compilers (e.g. C#, [Link], J#) will translate the
Code to Microsoft Intermediate Language (MSIL) and then transformed to
to be cont…
Native Code by CLR as shown in following figure,
Chapter 1
DOTNET Framework
1.3Common Language Runtime
to be cont…
Chapter 1
DOTNET Framework
Function of CLR
1. Code conversion:-
CLR provides the services and runtime environment to the
MSIL code. Internally CLR includes the JIT(Just-In-Time)
compiler which converts the MSIL code to machine code which
1. further. executed by CPU.
2. Exception Handling:-
CLR supports a standard exception-handling
mechanism that works across all languages, allowing
every program to use a common error-handling
mechanism to be cont…
Chapter 1
DOTNET Framework
Function of CLR
3. Type Safety :-
Types used in the application are verified with CTS or CLS
standards support by CLR .This provides type safety.
1. 4. Garbage
. collection:-
The memory of unused objects is freed
automatically with the help of garbage collector.
to be cont…
Chapter 1
DOTNET Framework
Function of CLR
5. Security :-
CLR converts the MSIL code into the native code .it performs
various security checks at runtime to make sure that the code is
safe to execute and that the code is not breaching any security
1.
requirements.
.
CLR provides secure execution for .NET
application. CLR use Role-Based Security and Code Access
Security for providing Secure Code Execution
6. Language Independence:--
CLR ensures language interoperability using
common type System(CTS).
Chapter 1
DOTNET Framework
.NET Execution Model/.NET compilation Process:-
1. .
to be cont…
Chapter 1
DOTNET Framework
.NET Execution Model/.NET compilation Process:-
The Code Execution Process involves the following two stages:
1. Compiler time process.
2. Runtime process.
1. .
to be cont…
1.1 Introduction to DOTNET
.NET Execution Model/.NET compilation Process:-
1. Compiler time process
The .Net framework has one or more language compilers, such as Visual
Basic, C#, Visual C++, JScript, or one of many third-party compilers such as an
Eiffel, Perl, or COBOL compiler.
Anyone of the compilers translates your source code into Microsoft
1. Intermediate Language
. (MSIL) code.
For example, if you are using the C# programming language to develop an
application, when you compile the application, the C# language compiler will
convert your source code into Microsoft Intermediate Language (MSIL) code.
In short, [Link], C#, and other language compilers generate MSIL code. (In
other words, compiling translates your source code into MSIL and generates
the required metadata.)
to be cont…
Chapter 1
DOTNET Framework
.NET Execution Model/.NET compilation Process:-
1. Compiler time process
Currently "Microsoft Intermediate Language" (MSIL) code is also known as the
"Intermediate Language" (IL) Code or "Common Intermediate Language" (CIL)
Code.
1. SOURCE CODE. -----.NET COMLIPER------> BYTE CODE (MSIL + META DATA)
to be cont…
Chapter 1
DOTNET Framework
.NET Execution Model/.NET compilation Process:-
2. Runtime process.
The Common Language Runtime (CLR) includes a JIT compiler for
converting MSIL to native code.
1. The JIT Compiler
. in CLR converts the MSIL code into native
machine code that is then executed by the OS.
During the runtime of a program, the "Just in Time" (JIT) compiler
of the Common Language Runtime (CLR) uses the Metadata and
converts Microsoft Intermediate Language (MSIL) into native code.
BYTE CODE (MSIL + META DATA) ----- Just-In-Time (JIT)
compiler------> NATIVE CODE
Chapter 1
DOTNET Framework
. 1.3.3Memory Management
Allocation Memory
Reserves a adjacent region of address space for the
process called managed heap.
Garbage Collector (GC)
It keeps a pointer to the address where the next object in
the heap will be allocated.
Reference types are allocation on the managed heap.
Allocating and access memory from the managed heap is
faster
to be cont…
Chapter 1
DOTNET Framework
. 1.3.3Memory Management
Deallocating Memory
When GC performs a collection ,it refers the memory for objects
that are no longer being used.
Garbage Collector (GC)
Roots of each application, either refers to an object on the managed
heap or is set to null.
GC can access the list of active roots that JIT complier and the
runtime environment.
For unmanaged resource, we explicitly have to call the Dispose
method to be cont…
Chapter 1
DOTNET Framework
1.3.4 Garbage Collector : Faster Memory
allocation, Optimizations
Garbage Collector (GC)
is one of the services that the CLR provides
Garbage Collector (GC)
Manage the allocation and release of memory of
an application.
Provides some ease to the developers in writing
the code.
to be cont…
Chapter 1
DOTNET Framework
1.4 Common Language Integration
1.4.1 Common Type System(CTS)
The Common Type System (CTS) standardizes the data types of
all programming languages using .NET under the umbrella
of .NET to a common data type for easy and smooth
1. communication
. among these .NET languages.
to be cont…
Chapter
1.1 1
Introduction to DOTNET
DOTNET Framework
1.4 Common Language Integration
1.4.1 Common Type System(CTS)
The intrinsic CTS data types
1. .
to be cont…
1.4 Common Language Integration
1.4.1 Common Type System(CTS)
The common type system supports two general
categories of types, each of which is further
divided into Value Types and Reference Types:-
1. .
Reference Types :-store a reference to the
memory address on the stack but the actual
value is stored on heap.
e.g.:-int[] Arr=new int[20];
In the above code the space required for the 2-
integers that make up the array is allocated
On the heap. to be cont…
Chapter 1 DOTNET Framework
1.4 Common Language Integration
1.4.1 Common Type System(CTS)
The common type system supports two general
categories of types, each of which is further
1.
divided. into Value Types and Reference Types:-
Value types:-directly contain the data. Actual
data is always stored on stack.
e.g.:- int x=10;
Here the value 10 is stored in an area of
memory called the stack. to be cont…
Chapter
1.1 1
Introduction to DOTNET
DOTNET Framework
1.4 Common Language Integration
1.4.1 Common Type System(CTS)
Type Casting or Type Conversion:-
1. .
Conversion between data types can be done in two
ways by casting:
Implicit casting
Explicit casting
to be cont…
Chapter 1
DOTNET Framework
1.4.1 Common Type System(CTS)
Type Casting or Type Conversion:-
Implicit casting
-Implicit casting doesn't require a casting operator. This
casting is normally used when converting data from
1. smaller integral
. types to larger or derived types to the base
type
int x = 123; double y = x;
In the above statement, the conversion of data from int to
double is done implicitly, in other words programmer don't
need to specify any type operators.
to be cont…
Chapter 1
DOTNET Framework
1.4.1 Common Type System(CTS)
Type Casting or Type Conversion:-
Explicit casting
Explicit casting requires a casting operator. This casting is
normally used when converting a double to int or a base
1. type to a .derived type.
double y = 123; int x = (int)y;
In the above statement, we have to specify the type
operator (int) when converting from double to int else the
compiler will throw an error
to be cont…
Chapter 1
DOTNET Framework
1.4.1 Common Type System(CTS)
Conversion Methods
Type Casting operator(explicit
casting)
Convert Class using
1. .
[Link]()
[Link]()
to be cont…
Chapter 1
DOTNET Framework
1.4 Common Language Integration
1.4.1 Common Type System(CTS)
Conversion Methods
[Link]() Convert Class [Link]()
It is used to convert It is used to convert It is used to convert
string to int any datatype to int string to int
1. .
Can not handle null Can handle null values Can handle null values
values
Will not check whether Will not check Will check whether
the type of parsing is whether the type of the type of parsing is
valid or invalid parsing is valid or valid or invalid
invalid
to be cont…
Chapter 1
DOTNET Framework
1.4 Common Language Integration
1.4.2 Reflection API
Reflection is the process of finding out about the internals
Of an application without having access to the source code. You can
use reflection to find all classes in an assembly and all the methods,
properties and events that might to be supported by each of those
1. classes. .
Reflection allows a c# program to inspect and manipulate itself from
the outside looking in. You can inspect all the information about a
class and also use reflection techniques to dynamically invoke
methods of the class at runtime.
Reflection allows you to view the information in the metadata
segment of your assemblies at runtime.
to be cont…
Chapter 1
DOTNET Framework
1.5 User and Program Interface
These tools enable users to develop user-friendly desktop-
based as well as web-based applications using a wide variety
of languages on the .NET platform.
Window Forms
1. [Link]
Console Application
to be cont…
Chapter 1
DOTNET Framework
Integrated Development Environment
• An Integrated Development Environment (IDE) is a software
application that offers complete accommodations to computer
developers for software development.
1. .
• In general, an IDE is a Graphical User Interface (GUI) based
work surface which assist the programmer in building software
applications by provided that tools like a source code editor,
build automation tools, a debugger etc. at hand.
• Visual Studio is the greatest frequently used IDE. C#.NET is
just an editor, providing by Microsoft to support programmer
to write .NET Programs simply.
to be cont…
Chapter 1
DOTNET Framework
Integrated Development Environment (IDE)
1. Start. Page Window of Visual Studio 2010