0% found this document useful (0 votes)
351 views40 pages

Unit-1 23022020041806AM

This document provides an introduction to the .NET framework. It discusses that the .NET framework provides a programming guideline for developing various applications. It consists of the Common Language Runtime (CLR) which acts as the execution engine, the Framework Class Library (FCL) which contains reusable classes and interfaces, and the Common Intermediate Language (CIL) into which code is compiled. The CLR is responsible for memory management, security, and executing the managed code. It converts the CIL into native machine code during runtime.

Uploaded by

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

Unit-1 23022020041806AM

This document provides an introduction to the .NET framework. It discusses that the .NET framework provides a programming guideline for developing various applications. It consists of the Common Language Runtime (CLR) which acts as the execution engine, the Framework Class Library (FCL) which contains reusable classes and interfaces, and the Common Intermediate Language (CIL) into which code is compiled. The CLR is responsible for memory management, security, and executing the managed code. It converts the CIL into native machine code during runtime.

Uploaded by

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

2160711

Dot Net Technology

Unit-1
Introduction
to .NET
Framework
Prof. Naimish R. Vadodariya
8866215253
[email protected]
Outline
 .NET Framework Overview
 .NET Framework Components
 Managed Code
 Unmanaged Code
 Managed code v/s Unmanaged code
 .NET Assemblies
 Garbage Collection
 Versioning and Side-by-Side Execution
 The END to DLL Hell – Managed Execution

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 22 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
.NET Framework Overview
 Why do we need a framework?
 Let us take an example
• If I told you to cut a piece of paper with dimensions 5cm by 5cm then surely
you would do that.
• But then I ask you to cut 1000 pieces of paper of the same dimensions.
• You won't do the measuring 1000 times, obviously you would make a frame
of 5cm by 5cm and then with the help of it you would be able to cut 1000
papers in less time.
• So, what you did is made a framework which would do that type of task and
performing the same type of task again and again for the same type of
applications.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 33 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
.NET Framework Cont..
 What is .NET framework?
• .NET (pronounced dot net) is a framework that provides a programming
guidelines that can be used to develop a wide range of applications–from
web to mobile to Windows-based applications.
• .NET framework runs on different versions of windows operating system,
starting from windows 95 to latest versions of windows 7 and windows 8 &
10.
• It is a framework that supports Multiple Language (40+) and Cross
language integration.
• .NET Framework also includes the .NET Common Language Runtime (CLR),
which is responsible for maintaining the execution of all applications
developed using the .NET library.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 44 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
.NET Framework Architecture

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 55 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
.NET Framework Components
 Common Language Runtime (CLR)
 Framework Class Library (FCL) = Base Class Library (BCL)
 Common Language Specification (CLS)
 Common Type System (CTS)
 Common Intermediate Language (CIL)

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 66 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Common Language Runtime (CLR)
 The CLR is the execution engine for .NET applications and serves as
the interface between .NET applications and the operating system.
 The CLR is somewhat comparable to the Java Virtual Machine (JVM)
that Sun Microsystems furnishes for running programs compiled
from the Java language.
• Programmers write code in any language like VB.NET, C# and F# etc.
• But when they compile their programs into an intermediate code
called MSIL that can be managed by the CLR and then the CLR
converts it into machine code to be executed by the processor.
• The CLR manages memory, Thread Execution, Garbage Collection
(GC), Exception Handling, Common Type System (CTS), code safety
verifications and other system services.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 77 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
CLR - Example
Source Code Byte Code Machine Code

CLR
C#
C# Code MSIL Code Native Code
Compiler

Compile Time Run Time

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 88 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
CLR Components
Class Library Support

Thread Support COM Marshaller

Type Checker Exception Manager

Security Engine Debug Engine

MSIL  Native
Code Garbage
Compilers
Manager Collector
(JIT)

Class Loader

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 99 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Functions of CLR
 Assembly Resolver
 Assembly Loader
 Type Checker
 COM marshalled
 Debug Manager
 Thread Support
 IL to Native compiler
 Exception Manager
 Garbage Collector
 Memory Management (using the Garbage Collector)
 Security
 Improved Performance
 Language Independency
 Platform Independency

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 10
10 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
.NET Framework Class Library (FCL)
 The .NET Framework Class Library (FCL) includes a huge collection
of reusable classes, interfaces, and value types that easy,
optimize and integrated with the CLR.
 It contains more than 7000+ classes and data types to read and
write files, access databases, process XML, display a graphical
user interface, draw graphics, create & consume of web services
etc.
 The .NET Framework Class Library (FCL) contains code supporting
for all the .NET technologies Like Windows Forms, ASP.NET,
ADO.NET, Windows Workflow, Windows Communication
Foundation & many more.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 11
11 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Common Language Specification(CLS)
 It defines a set of rules and restrictions that every language must
follow which runs under .NET framework.
 This is done in such a way, that programs written in any language
(.NET compliant) can interoperate with other languages.
 This also can take full advantage of inheritance, polymorphism,
exceptions, and other features.
 The languages which follows these set of rules are said to be CLS
Compliant Languages.
 In simple words, CLS enables Cross-Language Integration.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 12
12 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Common Type System (CTS)
 The Language interoperability, and .NET Class Framework, are not
possible without all the language sharing the same data types.
 CTS are the mechanism by which, code written in one
programming language can talk to code written in a different
programming language.
 Suppose we declare an integer variable like “int i;” remains same in
VB, VC++, C# and all other .NET compliant languages.
 It defines how types are declared, used and managed at the
runtime.
 It facilitates cross-language integration, type safety and high
performance code execution.
 It helps developers to develop applications in different languages.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 13
13 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Common Type System (CTS) Cont..
C#
(Int) CTS
VB (Int32)
(Integer)

 The common type system (CTS) supports two general categories of


data types:
• Value types : It can be built-in, user-defined or enumerations
types. (Boolean, Date, structs, and enums etc.)
• Reference types : It can be self describing types, pointers
types, or interface types. (Object)

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 14
14 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Common Type System (CTS) Cont..
Types

Value Types Reference Types

Built-in Value Types


Self describing Interface
Pointer Types
User-defined Value Type Types
Types

Enumerations Class Arrays

Structure
User-defined classes
Boxed Value Types
Delegates

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 15
15 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
MSIL = CIL = IL
• Microsoft Intermediate Language (MSIL) is a language used as the
output of a number of compilers (C#, VB, .NET, and so forth).
• Microsoft Intermediate Language (MSIL) is a CPU-independent set
of instructions that can be efficiently converted to the native
code.
• We can also call it as Intermediate Language (IL) or Common
Intermediate Language (CIL).
• When you compile a .NET Program, the CLR translates code into
MSIL code that can be converted into CPU specific code with the
help of JIT Compiler.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 16
16 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
MSIL = CIL = IL Cont..
 The MSIL code includes instruction to load, initialize and invoke
methods on objects.
 It also includes the instructions for various operations on program
code, such as arithmetic and logical operations, control flow,
direct memory access, exception handling etc.
 The program’s source code is converted to MSIL code, which is
equivalent to assembly language for CPU.
 The MSIL code is collected and assembled in the form of byte codes
and is converted to a .NET assembly.
 The .NET assembly code is executed by the JIT Compiler to generate
native code.
 The native code is executed by the computer’s processor.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 17
17 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Managed Code
 Managed code is the code that is executed directly by the CLR.
 The applications that are created using managed code
automatically have CLR services, such as type checking, security
and automatic garbage collection.
 These CLR services help to provide platform and language
independence to managed code applications.
 The CLR compiles the applications to Microsoft Intermediate
Language (MSIL) and not the machine code.
 This MSIL along with the metadata that describes the attributes,
classes, and methods of the code reside in assembly.
 The compilation takes place in managed execution environment,
which assures the working of the code.
Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 18
18 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Managed Code Cont..
Source program in languages like
VB.NET, C#, Jscript

Language Specific Compilers


vbc, csc, jsc

MSIL Code + Meta Data

JIT Compiler in CLR

Native Code

Processor

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 19
19 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Unmanaged Code
 Unmanaged code directly compiles to the machine code and runs
on the machine where it has been compiled.
 It does not have services, such as security or memory
management, which are provided by the runtime.
 If code is not security-prone, it can be directly interpreted by any
user, which is harmful.
 Applications that do not run under the control of the CLR are said
to be unmanaged.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 21
21 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Managed v/s Unmanaged Code
Managed Code Unmanaged Code
Code Executed by CLR Instead of Code which executed by operating
Operating System system directly
Runtime provide services like GC, Type
Does not provide the services like GC,
checking, Exception Handling. Type checking, Exception Handling taken
care by the programmer
The code compiled by the language Code will be compiled into native code.
compiler into MSIL code

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 22
22 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Namespace
 Namespace is a grouping of logically related identifiers, classes,
types etc.
 Namespace is used to avoid conflicts with the elements of an
unrelated code which have the same names.
 A namespace acts as a container—like a disk folder—for classes
organized into groups usually based on functionality.
 All classes and types of .NET FCL are organized in namespaces.
 Implementing Namespaces in your own code is a good habit
because it is likely to save you from problems later when you want
to reuse some of your code.
 Namespaces do not correspond to file or directory names.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 23
23 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
How to Create Namespace?
 Syntax: namespace namespace_name { }
namespace Demo
{
class Student
{
public void Student_Details()
{
Console.WriteLine("This is Student class");
}
}
class Subject
{
public void Subject_Details()
{
Console.WriteLine("This is Subject class");
}
}
}

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 24
24 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
How to Use Namespace?
using Demo;
using System; // Inbuilt Namespace
class Result
{
Subject s;
//Only class name, no need of namespace because we have used
in the beginning of code
System.Console.WriteLine("Hello");
//Full qualifier name because we have not included namespace.
Console.WriteLine("Hello");
// Console class belongs to System Namespace.
}

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 25
25 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Alias for Namespace
 We can create alias of any namespace.
 Syntax: using alias-name = namespace;

using Sys = System; // Alias Namespace

namespace Demo
{
class Student
{
public static void Main()
{
Sys.Console.WriteLine("This is Student class");
Sys.Console.WriteLine("Hello");
// Console class belongs to System Namespace.
}
}
}

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 26
26 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Nested Namespace
using System;
namespace Demo
{ namespace Parent
{ namespace Child
{ namespace Grandchild
{ class Test
{ public void ShowMessage()
{ Console.WriteLine("This is a nested
namespace!");
}
}
}
}
}
}

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 27
27 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Namespace Cont..
Namespace Description
System.Data Includes classes which lets us handle data from data sources.
System.Drawing Provides access to drawing methods.
System.IO Includes classes for data access with Files.
System.NET Provides interface to protocols used on the internet.
System.Security Includes classes to support the structure of common language
runtime security system.
System.Web Includes classes and interfaces that support browser-server
communication.
System.XML Includes classes for XML support.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 28
28 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Assembly - Example

Mother Board
Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 29
29 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
.NET Assembly
 Assembly is the smallest unit of deployment of a .NET applications. It can
be a dll or an exe.
 There are mainly two types to it:
• Private Assembly:
• The dll or exe which is sole property of one application only. It is generally stored in application
root folder.
• Public/Shared Assembly:
• It is a dll which can be used by multiple applications at a time.
• A shared assembly is stored in GAC i.e Global Assembly Cache.
 GAC is simply C:\Windows\Assembly folder where you can find the public
assemblies/dlls of all the softwares installed in your PC.
 There is also a third and least known type of an assembly: Satellite Assembly.
 A Satellite Assembly contains only static objects like images, text files and
other non-executable files required by the application.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 30
30 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
.NET Assembly Cont..
 Assembly contains four major parts.
 Manifest:
• Every assembly file contains information about itself. This information is called
as Assembly Manifest.
• The information includes version information, list of files packed, and definition
of types, security permissions, version control and metadata.
 Metadata:
• Metadata is binary information describing about your program that is stored
either in a CLR portable executable (PE) file or in memory.
 MSIL code:
• Containing business logics and also an Intermediate version of program.
 Set of Resource:
• Resources of an assembly like icons, text files, image files etc.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 31
31 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Garbage Collection
 The .NET Framework provides a new mechanism for releasing
unreferenced objects from the memory (that is no longer needed
objects in the program), is called Garbage Collection (GC).
 When a program creates an object, the object takes up the
memory.
 Later when the program has no more references to that object,
the object's memory becomes unreachable, but it is not
immediately freed.
 The Garbage Collection checks to see if there are any objects in
the heap that are no longer being used by the application. 

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 32
32 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Garbage Collection Cont..

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 33
33 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Garbage Collection Cont..
 If such objects exist, then the memory used by these objects can
be reclaimed.
 So these unreferenced objects should be removed from memory,
then the other new objects you create can find a place in the
Heap.
 This releasing of unreferenced objects is happening
automatically in .NET languages by the Garbage Collector (GC).

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 34
34 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Garbage Collection Cont..
 In .NET languages there is a facility that we can call Garbage
Collector (GC) explicitly in the program by calling
System.GC.Collect().
 Advantage of using Garbage Collector
• Allow us to develop an application without having worry to free memory.
• Allocates memory for objects efficiently on the managed heap.
• Reclaims the memory for no longer used objects and keeps the free
memory for future allocations.
• Provides memory safety by making sure that an object cannot use the
content of another object.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 35
35 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
End to DLL Hell
 Earlier, before the release of .NET, the term DLL Hell, has been
common in the world of software.
 DLL Hell refers to set of problems, which are caused when
multiple applications try to share a common component, for
instance a DLL file or a COM class.
• Suppose you install an application on your system.
• This application automatically updates a new version of the shared
component that is not backward compatible with a version already on the
machine.
• Although your new application that has just been installed works well, but
existing application that depended on previous version of the shared
component might no longer work.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 36
36 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
End to DLL Hell Cont..
 This is because the version information of different components
of an application is not recorded by the system.
 Therefore, changes made by an application on the system affect
other applications also.
 To end the problems of DLL Hell, Microsoft has introduced .NET
along the concept of run once – run forever.
 This means that if a .NET application is installed and works then it
will work forever, regardless of what other application,
including .NET as well as non .NET applications are installed on
your system.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 37
37 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Versioning & Side-by-Side Execution
 Side-by-side execution is the ability to store and execute multiple
versions of an application or component on the same computer.
 You can have multiple versions of the common language runtime
(CLR), and multiple versions of applications and components that
use a version of the runtime, on the same computer at the same
time.
 Versions 1.0 and 1.1 of the .NET Framework are designed to be
compatible with one another.
 An application built with the .NET Framework version 1.0 should
run on version 1.1, and an application built with the .NET
Framework version 1.1 should run on version 1.0

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 38
38 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Versioning & Side-by-Side Execution

App A App B App C App D

Comp V 1.2 Comp V 2.0 Comp V 3.0

Runtime V 1.0 Runtime V 1.1

Side by side
Execution

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 39
39 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Versioning & Side-by-Side Execution
 Applications A, B, and C use runtime version 1.0, while application
D uses runtime version 1.1.
 The runtime and the .NET Framework assemblies are versioned
separately.
 The .NET Framework consists of the common language runtime
and a collection of assemblies.
 The runtime and the .NET Framework assemblies are versioned
separately.
 For example, version 4.0 of the runtime is actually version 4.0.319,
while version 1.0 of the .NET Framework assemblies is version
1.0.3300.0.

Unit
Unit –– 11 :: Introduction
Introduction to
to .NET
.NET Framework
Framework 40
40 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology

You might also like