KEMBAR78
Introduction to dot net framework | PPTX
.Net Framework
Introduction to
.NET Framework
Outline
Introduction to .NET Framework
Architecture of .NET Framework
CLS, CLR, CTS, IL, CIL, MSIL
Before .NET
 Windows GUI development: Win32 API, MFC,
Visual Basic, COM
 Web development: ASP
 Java – “Write once, run anywhere. (WORA)”
What Is .NET
 .NET is a framework
 New Programming Paradigm
 .NET is platform independent / cross platform
 .NET is language-insensitive
.NET provides
 Integrated environment
 Internet, Desktop , Mobile devices
 consistent object-oriented
 To provide a portable environment
 Amanaged environment
.NET
Architecture
.NET Architecture …
.NET architecture is:
 multi-language
 cross-platform
 based on the CLR, FCL, and JIT technology
 .NET components are packaged as assemblies
.NET Architecture
Windows
Forms
Languages Supported by .NET
Over 35 languages are supported now
 C#, VB, Jscript, Visual C++
 Perl, Python, Smalltalk,
 Cobol, Haskell, Mercury, Eiffel,
 Oberon, Oz, Pascal,
 APL, CAML, Scheme, etc.
Common Type System (CTS)
• A specification for how types are
defined and how they behave.
• no syntaxspecified
• A type can contain zero or more
members:
• Field
• Method
• Property
• Event
Common Type System (CTS)
CTS is a formal specification that describes
how a given type must be defined for CLR
• CTS Class Type
• CTS Structure Type
• CTS Interface Type
• CTS Enumeration type
• CTS Delegate type
CTS Class Type
• Same as C++ class
• Can contain members: methods,
properties, events, etc.
• Support for abstract members that
define a polymorphic interface for
derived classes
• Multiple inheritance is not allowed
CTS Class Characteristics
• "sealed"? – sealed classes can't function as
base classes
• Implement any interfaces? – An
interface is a collection of abstract
members
• Abstract or Concrete? – Abstract classes (to
define common behaviors for derived) can't be
created directly but concrete classes can.
• Visibility? – visibility attribute to know
whether external assemblies can use it.
CTS Structure types
 Same as C/C++
 Derived from a common base class
System.ValueType
CTS Enumeration type
To group name/value pairs under a
specific name Default Storage:
System.Int32 (could be Changed)
CTS Interface types
CTS Delegate type
• Same as pure abstract class of C++
• A description of work that a derived
class can perform
• Similar to a class, but can never be
instantiated
• Same as C's function pointer
(System.MulticastDelegate)
• Useful for event handling (ASP .NET)
CTS Data Types
.NET Base Type C# Type
System.Byte Byte
System.SByte sbyte
System.Int16 short
System.Int32 int
System.Int64 long
System.UInt64 ulong
System.Single float
System.Double double
System.Object object
System.String string
System.Boolean bool
CLS Compliance
C# Type CLS Compliance
byte Yes
sbyte No
short Yes
int Yes
long Yes
ulong No
float Yes
double Yes
object Yes
string Yes
char Yes
Common Language Runtime
 A common runtime for all .NET
languages
Common type system
Common metadata
Intermediate Language (IL) to native code
compilers
Memory allocation and garbage collection
Code execution and security
Common Language Runtime
 Execution Engine
 Compiles Microsoft Intermediate
Language (MSIL) into nativecode
 Handles garbagecollection
 Handles exceptions
 Enforces code accesssecurity
 Handles verification
 Managed v.Unmanaged Code
CLR Execution Model
Source
code
VB C# C++
Compiler Compiler Compiler
Assembly
IL Code
Assembly
IL Code
Assembly
IL Code
Common Language Runtime
JIT Compiler
Native Code
Operating System Services
Managed
code
Unmanaged
Component
Advantages of CLR
• Support for developer services (debugging)
• Interoperation between managed code and
unmanaged code (COM,DLLs).
• Managed code environment
• Improved memory handling
• Improved “garbagecollection”
Advantages of CLR
• JIT allows code to run in a protected environment
as managed code.
• JIT allows the IL code to be hardware
independent.
• CLR also allows for enforcement of code
access security.
• Verification of type safety.
CLR .NET
Source
Code
Base Class
Libraries
(mscorlib.dll)
.NET Execution Engine
Class Loader
Jitter
Platform
Specific code
Execute
.NET Compiler
DLL or EXE
(CIL)
mscoree.dll
mscoree.dll
MicroSoft Common
Object Runtime Execution Engine
Dot Net Namespaces
• MFC, Java, VB 6.0 have predefined set of
classes; C# doesn't
• C# uses namespace concept
• Any language targeting the .NET runtime
makes use of the same namespaces and
same types as C#
• System is the root namespace
Sample .NET namespaces
System
primitive types, garbage
collection, etc
System.Collections Container objects: ArrayList, Queue,
etc.
System.Data
System.Data.Common
System.Data.OleDb
System.Data.SqlClient
For Database manipulations ADO .NET
System.IO file IO, buffering, etc.
System.Drawing
System.Drawing.2D
GDI+ primitives, bitmaps, fonts, icons, etc.
System.Threading Threads
Common Data Types
CLR provides a set of primitive types that all
languages must support.The datatypes
include:
 Integer—three types 16/32/64bits
 Float—two types: 32/64 bits
 Boolean and Character
 Date/time and Time span
The primitive types can be collected into
 Arrays
 Structures
 Combination of the two
Common Language Specification (CLS)
Not all languages support all CTS types and features
 C# is case sensitive, VB.NET is not
 C# supports pointer types (in unsafe mode),
VB.NET does not
 C# supports operator overloading, VB.NET does not
CLS was introduced to promote language
interoperability
 vast majority of classes within FCL are CLS-compliant
Comparison to Java
Hello.java Hello.class JVM
compile execute
Hello.vb Hello.exe CLR
compile execute
Source code Bytecode
CILSource code
Base Class Library @ FCL
Unified Classes
Web Classes (ASP.NET)
Controls, Caching, Security, Session, Configuration etc
System Classes
Collections, Diagnostics, Globalization, IO, Security,
Threading Serialization, Reflection, Messaging etc
Data (ADO.NET)
ADO, SQL,Types etc
Drawing Classes
Drawing, Imaging, Text, etc
Windows Forms
Design, Cmpnt Model etc
XML Classes
XSLT, Path, Serialization etc
Framework Class Library @ BCL
Single consistent set of object oriented class
libraries to enable building distributed web
applications (Unified Classes)
Built using classes arranged across logical
hierarchical namespaces
Work with allCLR languages
Summary
Introduction to .NET Framework
Architecture of .NET Framework
CTS, CLR, IL, MSIL, CIL
Introduction to dot net framework
Introduction to dot net framework

Introduction to dot net framework

  • 1.
  • 2.
  • 3.
    Outline Introduction to .NETFramework Architecture of .NET Framework CLS, CLR, CTS, IL, CIL, MSIL
  • 4.
    Before .NET  WindowsGUI development: Win32 API, MFC, Visual Basic, COM  Web development: ASP  Java – “Write once, run anywhere. (WORA)”
  • 5.
    What Is .NET .NET is a framework  New Programming Paradigm  .NET is platform independent / cross platform  .NET is language-insensitive
  • 6.
    .NET provides  Integratedenvironment  Internet, Desktop , Mobile devices  consistent object-oriented  To provide a portable environment  Amanaged environment
  • 7.
  • 8.
    .NET Architecture … .NETarchitecture is:  multi-language  cross-platform  based on the CLR, FCL, and JIT technology  .NET components are packaged as assemblies
  • 9.
  • 10.
    Languages Supported by.NET Over 35 languages are supported now  C#, VB, Jscript, Visual C++  Perl, Python, Smalltalk,  Cobol, Haskell, Mercury, Eiffel,  Oberon, Oz, Pascal,  APL, CAML, Scheme, etc.
  • 11.
    Common Type System(CTS) • A specification for how types are defined and how they behave. • no syntaxspecified • A type can contain zero or more members: • Field • Method • Property • Event
  • 12.
    Common Type System(CTS) CTS is a formal specification that describes how a given type must be defined for CLR • CTS Class Type • CTS Structure Type • CTS Interface Type • CTS Enumeration type • CTS Delegate type
  • 13.
    CTS Class Type •Same as C++ class • Can contain members: methods, properties, events, etc. • Support for abstract members that define a polymorphic interface for derived classes • Multiple inheritance is not allowed
  • 14.
    CTS Class Characteristics •"sealed"? – sealed classes can't function as base classes • Implement any interfaces? – An interface is a collection of abstract members • Abstract or Concrete? – Abstract classes (to define common behaviors for derived) can't be created directly but concrete classes can. • Visibility? – visibility attribute to know whether external assemblies can use it.
  • 15.
    CTS Structure types Same as C/C++  Derived from a common base class System.ValueType CTS Enumeration type To group name/value pairs under a specific name Default Storage: System.Int32 (could be Changed)
  • 16.
    CTS Interface types CTSDelegate type • Same as pure abstract class of C++ • A description of work that a derived class can perform • Similar to a class, but can never be instantiated • Same as C's function pointer (System.MulticastDelegate) • Useful for event handling (ASP .NET)
  • 17.
    CTS Data Types .NETBase Type C# Type System.Byte Byte System.SByte sbyte System.Int16 short System.Int32 int System.Int64 long System.UInt64 ulong System.Single float System.Double double System.Object object System.String string System.Boolean bool
  • 18.
    CLS Compliance C# TypeCLS Compliance byte Yes sbyte No short Yes int Yes long Yes ulong No float Yes double Yes object Yes string Yes char Yes
  • 19.
    Common Language Runtime A common runtime for all .NET languages Common type system Common metadata Intermediate Language (IL) to native code compilers Memory allocation and garbage collection Code execution and security
  • 20.
    Common Language Runtime Execution Engine  Compiles Microsoft Intermediate Language (MSIL) into nativecode  Handles garbagecollection  Handles exceptions  Enforces code accesssecurity  Handles verification  Managed v.Unmanaged Code
  • 21.
    CLR Execution Model Source code VBC# C++ Compiler Compiler Compiler Assembly IL Code Assembly IL Code Assembly IL Code Common Language Runtime JIT Compiler Native Code Operating System Services Managed code Unmanaged Component
  • 22.
    Advantages of CLR •Support for developer services (debugging) • Interoperation between managed code and unmanaged code (COM,DLLs). • Managed code environment • Improved memory handling • Improved “garbagecollection”
  • 23.
    Advantages of CLR •JIT allows code to run in a protected environment as managed code. • JIT allows the IL code to be hardware independent. • CLR also allows for enforcement of code access security. • Verification of type safety.
  • 24.
    CLR .NET Source Code Base Class Libraries (mscorlib.dll) .NETExecution Engine Class Loader Jitter Platform Specific code Execute .NET Compiler DLL or EXE (CIL) mscoree.dll mscoree.dll MicroSoft Common Object Runtime Execution Engine
  • 25.
    Dot Net Namespaces •MFC, Java, VB 6.0 have predefined set of classes; C# doesn't • C# uses namespace concept • Any language targeting the .NET runtime makes use of the same namespaces and same types as C# • System is the root namespace
  • 26.
    Sample .NET namespaces System primitivetypes, garbage collection, etc System.Collections Container objects: ArrayList, Queue, etc. System.Data System.Data.Common System.Data.OleDb System.Data.SqlClient For Database manipulations ADO .NET System.IO file IO, buffering, etc. System.Drawing System.Drawing.2D GDI+ primitives, bitmaps, fonts, icons, etc. System.Threading Threads
  • 27.
    Common Data Types CLRprovides a set of primitive types that all languages must support.The datatypes include:  Integer—three types 16/32/64bits  Float—two types: 32/64 bits  Boolean and Character  Date/time and Time span The primitive types can be collected into  Arrays  Structures  Combination of the two
  • 28.
    Common Language Specification(CLS) Not all languages support all CTS types and features  C# is case sensitive, VB.NET is not  C# supports pointer types (in unsafe mode), VB.NET does not  C# supports operator overloading, VB.NET does not CLS was introduced to promote language interoperability  vast majority of classes within FCL are CLS-compliant
  • 29.
    Comparison to Java Hello.javaHello.class JVM compile execute Hello.vb Hello.exe CLR compile execute Source code Bytecode CILSource code
  • 30.
    Base Class Library@ FCL Unified Classes Web Classes (ASP.NET) Controls, Caching, Security, Session, Configuration etc System Classes Collections, Diagnostics, Globalization, IO, Security, Threading Serialization, Reflection, Messaging etc Data (ADO.NET) ADO, SQL,Types etc Drawing Classes Drawing, Imaging, Text, etc Windows Forms Design, Cmpnt Model etc XML Classes XSLT, Path, Serialization etc
  • 31.
    Framework Class Library@ BCL Single consistent set of object oriented class libraries to enable building distributed web applications (Unified Classes) Built using classes arranged across logical hierarchical namespaces Work with allCLR languages
  • 32.
    Summary Introduction to .NETFramework Architecture of .NET Framework CTS, CLR, IL, MSIL, CIL