Anda di halaman 1dari 43

Mr. G.C.

Lecturer, CSE@KLS.GIT

The .NET Vision

Seeing brings about
evolution. Vision brings about
.NET is Microsofts vision of
how computing is going to
take place in future. .NET
offers a whole new paradigm
that will change the way you
think about writing software.

Topic Level Objectives

To lay the conceptual groundwork for remaining
To confabulate about .NET related topics such as
assemblies, the
Common Intermediate Language (CIL), and just-intime (JIT)
To preview some key features of the C#
programming language.
To throw light on the relationship between various
aspects of the
.NET Framework, such as Common Language
Runtime (CLR),
the Common Type System (CTS), and the Common

Intended Learning Outcomes

1. Investigate limitations and complexities found within the

technologies prior to .NET [L 4].

2. Explain the building blocks of .NET platform [L 2].
3. Discuss the role of .NET base class libraries [L 2].
4. Discuss the role of CIL and its benefits [L 2].
5. Distinguish between single-file and multi file assemblies [L 2].
6. Discuss the role of .NET type metadata and assembly manifest

[L 2].
7. Explain the CTS and CLR [L 2].
8. Discuss Common Language Specification [L 2].
9. Write CLS compliant code [L 5].
10. Deploy the .NET runtime [L 3].

Understanding the Previous

State of Affairs
Life As a C/Win32 API Programmer
Life As a C++/MFC Programmer
Life As a Visual Basic 6.0

Life As a Java/J2EE Programmer
Life As a COM Programmer
Life As a Windows DNA Programmer

Life As a C/Win32 API

C +Windows API
Complex undertaking
C is terse language
Manual memory management
Ugly pointer arithmetic
Ugly syntactical constructs

Lacks object-oriented approach

Life As a C++/MFC Programmer

Improvement over C/API
Continuation of painful aspects of C

MFC- C++ Framework provides set of

existing C++ classes that facilitate the

construction of Windows Applications.
C++ remains as a difficult and error-prone


Life As a VB 6.0 Programmer

Kinder and gentler language
Build Complex UI, Code libraries, Data Access

Integrated code wizards, Intrinsic data types,
classes and VB-centric functions
Not fully object oriented
No classical inheritance
No support for parameterized class
No support for multithreaded applications

Life As a Java/J2EE programmer

Almost completely object oriented
Java is Language + Platform
Little hope for language

independence (against Javas

primary goal)
Not appropriate for graphically and
numerically intensive applications
Little support for true cross
language integration

Life As a COM Programmer

If you build your classes in accordance with the

rules of COM, you end up with a block of reusable

binary code
Binary COM servers can be accessed in a language
independent manner
Limited language independence (no classical
inheritance) has-a relationship
Location transparent nature(AppIDs, stubs, proxies,
com runtime environments). Avoid raw sockets and
RPC calls
DLL hell problem (registration and deployment

Life As a Windows DNA

Distributed iNternet Architecture
Windows DNA (ASP,HTML,

XML,ADO, VBScript, JavaScript,

Syntactically unrelated
Each language has its own type

The .NET Solution

Full Interoperability with existing

Complete and total language

A common runtime engine shared
by all .NET-aware languages
A base class library
No more COM plumbing
A truly simplified deployment model

Building Blocks of the .NET


Figure 1.1: The CLR, CTS, CLS and base class library

What C# Brings to the Table

No pointers required !
Automatic memory management
Formal syntactic constructs
C++ like abilities
Generic types and generic members
Full support for Interface-based

programming techniques
Full support for aspect-oriented
programming (AOP) techniques

An Overview of .NET

Figure 1.2: All .NET-aware compilers emit IL instructions

and metadata

The Role of the CIL

The Role of the CIL

The Role of the CIL

The Role of the CIL

The Role of the CIL

Benefits of CIL
Language Integration

Compiling CIL to Platform-Specific

just-in-time compiler or jitter
Jitter for handheld device low memory environment
Jitter for Backend server high memory environment

The Role of .NET Type Metadata

Describes each and every type (class,

structs) defined in the binary and members

(methods, properties) of each type
Compiler emits the latest type metadata
Intellisense feature of VS
Debugging tools
C# Compiler
Backbone of WCF, Reflection, late binding,

Object serialization etc

The Role of .NET Type Metadata

(methods, properties)

The Role of Assembly Manifest

Metadata that describes assembly itself
The manifest documents all external

assemblies required by the current

assembly to function correctly, the
assemblys version number, copyright
information, and so forth.
Generated by compiler

The Role of the Assembly


The Common Type System

CTS class types
CTS structure types
CTS Interface types
CTS Enumeration types
CTS delegate types
CTS type members
Intrinsic CTS data types

CTS class types

Table 1.1: CTS class


CTS structure types

Differences between classes

and structs
Structs are value types
All struct types implicitly inherit from the class

Assignment to a variable of a struct type creates a
copy of the value being assigned
The default value of a struct is the value produced by
setting all value type fields to their default values and
all reference type fields to null
Boxing and unboxing operations are used to convert
between a struct type and object
The meaning of this is different for structs
A struct is not permitted to declare a parameterless
instance constructor
A struct is not permitted to declare a destructor

CTS Interface types

CTS Enumeration types

CTS delegate types

Intrinsic CTS data types

Table 1.2: The intrinsic CTS
data types

The Common Language


Rule 1: CLS rules apply only to those parts

of a type that are exposed outside the
defining assembly

The Common Language


Ensuring CLS Compliance

The Common Language


Figure 1.3: mscoree.dll in action

The .NET Namespaces

Accessing a Namespace Programmatically
Referencing External Assemblies

The .NET Namespaces

The .NET Namespaces

The .NET Namespaces

1] Andrew Troelsen, Pro C#with.NET 3.0, SpecialEdition,
Dream tech Press, India, 2007.
2]E. Balagurusamy, Programming in C#, 5thReprint, Tata
McGraw Hill,
2004(For Programming Examples).
3] Tom Archer, Inside C#, WP Publishers, 2001.
4]Herbert Schildt,C#: The Complete Reference, TMH, 2004.
5] Yashavant Kanetkar, C#.NET fundas, First Edition, BPB

Contact Me
Follow on twitter: