Anda di halaman 1dari 35

LECTURE

Introduction to .NET
Framework
SEN 442
Visual Programming
Spring 2016

Ali Mirza
Assistant Professor
ghulamali84@hotmail.com

Department of Computer Science


Bahria University, Islamabad

Lecture
Outline
Brief History
What is .NET and Important components
Compilation Model
Incremental .NET Framework Stack
CLR Versions and
Side By side Execution

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

l
l
a
l
!
s
a
n
t
!
o
i
n
t
ItI s ou
o
i
u
t
l
l
v
o
E
Ev
Scripting

Machine

Assembl
y

Procedur
al

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

Object
Oriented

Function
al

Declarati
ve

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Code
Reusabilit
y

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

Platform
Independe
nce

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Evolved to
Great
Maturity

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

Learned lot
from Previous
Experiences

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Visual
C#

VB.NET

VC+
+.NET

F#

JavaScri
pt

Third
Party

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Console
Applications

Windows
Services

Client/Deskt
op
Applications

Server/Web
Applications

Win
Forms

ASP.NET
Web
Forms

WPF

ASP.NET
MVC

Win Store
Apps

Smart
Device
Applications

XML Web
Services
WCF
Services

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

.NET
Framework
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Is
Is run-time
run-time environment
environment to
to
execute
.NET
Apps
execute .NET Apps
Code
Code Execution
Execution
Exception
Exception Handling
Handling
Resource
Management
Resource Management
Garbage
Garbage Collection
Collection
Code
Access
Code Access Security
Security
Just
In
Time
Compilation
Just In Time Compilation
Language
Language Interoperability
Interoperability
Application
Application Isolation
Isolation

Framewor
k Class
Library

.NET
Framework

Library
Library of
of tested,
tested, reusable
reusable code
code that
that
developers
developers can
can use
use in
in own
own applications
applications
Consists
of
classes,
interfaces,
Consists of classes, interfaces, and
and structures,
structures,
delegates
etc.
delegates etc.
Categorized
Categorized using
using Namespaces
Namespaces

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

Commo
n
Languag
e
Runtime
SEN 442 Visual
Programming
Introduction to .NET. 2
Framework

Classic Compilation Vs. .NET Compilation


C# Source Code

Using FCL
Classes

C Source Code
C# Compiler

C Compiler
Assembly [CIL]
OS

Machine Code
Executed
by OS

JIT
CLR

Machine Code
OS

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

FCL
Assembli
es

Executed by
CLR
SEN 442 Visual
Programming
Introduction to .NET. 2
Framework

Common
Common Intermediate
Intermediate Language
Language
Earlier
called
Microsoft
Earlier called Microsoft Intermediate
Intermediate Language
Language
or
MSIL
or
IL
or MSIL or IL
Also
Also referred
referred as
as Managed
Managed Code
Code
Is
an
object-oriented
assembly
Is an object-oriented assembly language
language
Advantages
Advantages
Optional
part
Optional
partIndependence
Platform
Platform
Independence
Details
of
resources
if
Information
about
all
in
of external
external
resources
if used
used
Details
Language
Information
all types
types used
used
in source
source
Independence
Languageabout
Independence
code
code

Information
about
Consist
of
and
Information
about assembly
assembly
Consist
of Meta-information
Meta-information
and CIL
CIL

Assembly
name
Basic
Building
blocks
of
.NET
Framework

Assembly
name
Basic Building blocks of .NET Framework
Assembly
Self
Assembly Version
Version
Self Descriptive
Descriptive

Two
Security
Security Key
Key
Two Types
Types

Private
References
References to
to other
other assemblies
assemblies used
used
Private
Public
Public

Meta Information
Assembly
Manifest
Type
Metadata
Resources

CIL

Assembly
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Platform Independence
Development Platform

Assembly
Assembly

Production Platform

Resources
Resources required
required to
to develop
develop and
and execute
execute the
the
applications
applications
FCL
Typically
a
architecture
and
C# Source
Code
Class includes
Typically
includes
a hardware
hardware
architecture
and a
a
CLR
software
framework
(Uses
ref
of
dlls
from
FCL)
(Uses ref of dlls from FCL)
Ref
software
framework

Assembly
Loader
C# Compiler

Assembly
Meta
Information

(exe / dll)

FCL

JIT
Machine Code

CIL Code

.NET Framework
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Language Independence
VB.NET
Code

C# Code

F# / C+
+.NET/ Any
CLS
compatible

VB.NET
Compiler

C#
Compiler

Lang
Compiler

CIL

JIT

CLR

FCL
FCL
Native
Code

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

.NET
Framework
Revisited
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Common
Common Language
Language Infrastructure
Infrastructure is
is an
an
international
standard
that
is
the
basis
CLS
works
with
the
CTS
to
ensure
international
standard
is the basis
CLS works with
the CTSthat
to ensure
for
creating
execution
and
Common
Type
System
language
interoperability
for
creating
executionType
and System defines
Common
defines
language
interoperability
development
environments
in
which
the
set
The
CLS
is
a
set
of
minimum
standards
development
environments
which
set
The CLS is athe
set
of minimuminstandards
languages
and
libraries
work
together
predefined
data
types
available
that
all
compilers
targeting
.NET
must
languages
and
libraries
work.NET
together
predefined
data
types
available
that all compilers
targeting
must
seamlessly.
in
IL
support.
seamlessly.
in IL
support.

FCL

Is
environment
to
Code
Security
Is run-time
run-time
environment
to the
Code Access
Access
Security Applies
Applies
the
execute
.NET
Apps
permission
to
code,
based
on
execute
.NETtoApps
permission
code, based on source
source of
of
Commercial
implementation
of
CLI
by
code
and
other
identities
Commercial
implementation
of CLI by
code and CIL
other
identities
Compiles
to
Machine
code
Compiles
CIL
to
Machine
code
Microsoft
Microsoft
compiles
portion
compiles
portion of
of code
code as
as it
it is
is called.
called.
Code
Execution
Code
Execution
And

cached
garbage
collector
manages
the
And
Exception
cached collector
garbage
Handling
Exception
Handlingmanages the
allocation
and
allocationManagement
and release
release of
of memory
memory for
for
Resource
Resource
Management
your
application.
your application.
Garbage
Collection
Garbage
Collection
Code
Reclaims
unreferenced
or
Reclaims
unreferenced
or dead
dead objects
objects
Access
Security
Code
Access
Security
and
clears
their
memory.
and In
clears
memory.
Just
Time
Compilation
Just
In
Timetheir
Compilation
Language
Language Interoperability
Interoperability
Application
Application Isolation
Isolation

CLR
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

JIT

CLS CTS

CA
S

G
C

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

FCL
Library
of
reusable
code
Library
of tested,
tested,
reusable
code that
that
Provides
architecture
to
develop
web
Provides
architecture
to
develop
web applications
applications
developers
can
use
in
own
applications
developers
can
use
in
own
applications
and
web
services.
Subsets
are
and web
services. Subsets are and structures,
Consists
of
Consists
of classes,
classes, interfaces,
interfaces, and structures,
WebForms
WebForms
delegates
etc.
delegates
etc.
XML
XML WebServices
WebServices
Categorized
Categorized using
using Namespaces
Namespaces

Namespaces
Namespaces support
support the
the hierarchical
hierarchical
organization
of
classes
and
organization of classes and prevent
prevent type
type
Provides
architecture,
library
and
controls
name
collisions
Provides
architecture, library and controls to
to
name
collisions
develop
desktop
applications.
develop desktop applications.

WinForms
WinForms

ADO.NET
ADO.NET

Set
Set of
of classes
classes to
to be
be used
used for
for database
database
communication
communication
Set
Set of
of common
common classes
classes need
need in
in various
various types
types of
of
applications.
applications.
Typically
Typically classes
classes in
in System
System namespace.
namespace.

2.
2005
0

Base Framework Library


Base Framework Library
CLR
CLR

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

ASP.NET

ASP.NET / Web
WebForms
Services
WebForms
/ Web
Services

JIT

CLS CTS

CA
S

G
C

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

presentation
presentation system
system for
for building
building Windows
Windows client
client
applications
with
visually
stunning
user
applications with visually stunning user
experiences.
experiences.
resolution-independent
resolution-independent and
and vector-based
vector-based
rendering
engine
rendering engine
Features:
Features: XAML,
XAML, 3D
3D Graphics,
Graphics, Animation,
Animation, Media,
Media,
etc
etc
framework
framework for
for building
building service-oriented
service-oriented
applications.
applications.
Workflows
Workflows provide
provide a
a way
way of
of describing
describing the
the
order
of
execution
and
dependent
order of execution and dependent
relationships
relationships between
between pieces
pieces of
of shortshort- or
or
long-running
work.
long-running work.
provides
provides a
a standards-based
standards-based solution
solution for
for
working
with
and
managing
diverse
digital
working with and managing diverse digital
identities.
identities.
Discontinued
Discontinued from
from Feb
Feb 2011
2011
Microsoft
is
currently
working
Microsoft is currently working on
on a
a
replacement
called
U-Prove
replacement called U-Prove

FCL

WPF

WCF

WinForms

WF

CardSpa
ce

ASP.NET

WebForms / Web
Services

ADO.NET
2.
2005
0

Base Framework Library


CLR
CLR
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

3.
02006

JIT

CLS CTS

CA
S

G
C

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

FCL
set
set of
of features
features introduced
introduced in
in Visual
Visual Studio
Studio 2008
2008
that
extends
powerful
query
capabilities
to
that extends powerful query capabilities to the
the
language
syntax
of
C#
and
Visual
Basic.
language syntax of C# and Visual Basic.

New
New server
server controls
controls and
and ASP.NET
ASP.NET AJAX
AJAX

Enhancements
Enhancements in
in Common
Common Language
Language Runtime
Runtime
Enhancements
in
WPF,
WCF,
Networking,
Enhancements in WPF, WCF, Networking,
Windows
Windows Forms,
Forms, etc
etc

LINQ

ASP.NET
3.5, AJAX

CLR, Other
Enhanceme
nts

WPF

WCF

WF

WinForms

3.
2006
0

ASP.NET

WebForms / Web
Services

ADO.NET
2.
2005
0

Base Framework Library


CLR
CLR
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

3.
2007
5

JIT

CLS CTS

CA
S

G
C

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

FCL

object-relational
object-relational mapper
mapper that
that enables
enables .NET
.NET
developers
to
work
with
relational
data
developers to work with relational data using
using
domain-specific
objects.
It
eliminates
the
domain-specific objects. It eliminates the
need
need for
for most
most of
of the
the data-access
data-access code
code that
that
developers
usually
need
to
write.
developers usually need to write.

ASP.NET
ASP.NET Dynamic
Dynamic Data
Data lets
lets you
you create
create
extensible
data-driven
Web
applications
extensible data-driven Web applications by
by
inferring
at
run
time
the
appearance
and
inferring at run time the appearance and
behavior
behavior of
of data
data entities
entities from
from the
the database
database
schema
and
deriving
UI
behavior
from
schema and deriving UI behavior from it.
it.

Entity
Framework

Dynamic Data

LINQ

ASP.NET
3.5, AJAX

WPF

WCF

WinForms

3.
CLR, Other
2007
Enhanceme 5
nts

WF

3.
2006
0

ASP.NET

WebForms / Web
Services

ADO.NET
2.
2005
0

Base Framework Library


CLR
CLR
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

3.5s
2
p008

JIT

CLS CTS

CA
S

G
C

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

FCL
Parallel
Parallel LINQ
LINQ (PLINQ)
(PLINQ) is
is a
a parallel
parallel
implementation
of
LINQ
to
implementation of LINQ to Objects.
Objects.

powerful,
Task
Parallel
set
the
patterns-based
way
Task
Parallel Library
Library
set APIs
APIs in
in
theto
powerful,
patterns-based
way
to build
build
System.Threading
and
dynamic
websites
System.Threading
and
dynamic websites

System.Threading.Tasks
namespaces
enables
a
clean
of
enables a clean separation
System.Threading.Tasks
namespaces
separation
of concerns
concerns

Efficiently
use
all
the
available
gives
full
control
over
markup
gives full
Efficiently
usecontrol
all theover
available
markup

processors
Provides
features
that
Provides features that enable
processors
enable fast
fast Test
Test
Driven
Driven Development
Development for
for creating
creating
sophisticated
sophisticated applications
applications that
that use
use the
the
latest
web
standards.
latest web standards.
The
The Portable
Portable Class
Class Library
Library project
project enables
enables you
you
to
write
and
build
managed
assemblies
that
to write and build managed assemblies that
work
work on
on more
more than
than one
one .NET
.NET Framework
Framework
platform.
platform.

TPL

PLIN
Q

PCL

4.
2010
0

Dynamic Data

3.5s
2008
p1

MVC

Entity
Framework
LINQ

ASP.NET
3.5, AJAX

WPF

WCF

WinForms

CLR, Other
Enhanceme 3.
2007
nts
5

WF

3.
2006
0

ASP.NET

WebForms / Web
Services

ADO.NET
2.
2005
0

Base Framework Library


CLR
CLR
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

JIT

CLS CTS

CA
S

G
C

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

A
A Windows
Windows Store
Store app
app is
is a
a new
new type
type of
of app
app
that
is
sold
in
the
Windows
Store
and
runs
that is sold in the Windows Store and runs
on
on Windows
Windows 8
8 devices.
devices.
Microsoft
Windows
Microsoft Windows Metro
Metro is
is the
the clean,
clean,
dynamic,
and
content-focused
UI
dynamic, and content-focused UI in
in
Windows
8.
Windows 8.
HTML5
HTML5 offers
offers new
new features
features (elements,
(elements,
attributes,
event
handlers,
and
attributes, event handlers, and APIs)
APIs) for
for easier
easier
web
application
development
and
more
web application development and more
sophisticated
sophisticated form
form handling.
handling.
JQuery
is
powerful
JavaScript
JQuery is powerful JavaScript library
library
CSS
is
used
to
control
the
style
CSS is used to control the style and
and layout
layout of
of
Web
pages.
CSS3
is
the
latest
standard
for
Web pages. CSS3 is the latest standard for CSS
CSS
WebSocket
WebSocket establishes
establishes persistent
persistent connection
connection
between
the
client
and
the
server
between the client and the server and
and both
both
parties
can
start
sending
data
at
any
time.
parties can start sending data at any time.

FCL
Windows
store Apps

PLIN
Q

HTML 5, /
CSS3/
JQuery

TPL

Web
Socket

MVC

Entity
Framework

PCL

Dynamic Data

3.5s
2
p008

LINQ

ASP.NET
3.5, AJAX

CLR, Other
Enhanceme
nts

3.
2007
5

WPF

WCF

WF

3.
2006
0

WinForms

ASP.NET

WebForms / Web
Services

ADO.NET

2.
2005
0

Base Framework Library


CLR
CLR
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

2012
4.
5
4.
2010
0

JIT

CLS CTS

CA
S

G
C

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Architecture

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Compiling and executing


managed code
Compilation
Sourc
e
Code

Languag
e
Compiler

Microsoft
Intermedia
te
Language
(MSIL)
The first time
each method is
called

Native
Code

JIT
Compiler
Execution

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Common Language Runtime

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Some .NET Base Class Libraries


System.Web

System.WinForms

Services
Description

UI
HtmlControls

Discovery

WebControls

Design

Protocols

ComponentModel

System.Drawing

Caching

Security

Drawing2D

Printing

Configuration

SessionState

Imaging

Text

System.Data

System.Xml

ADO

SQL

XSLT

Design

SQLTypes

XPath

Serialization

System
Collections

IO

Security

Configuration

ServiceProcess

Diagnostics

Net
Reflection

Text

Remoting

Globalization

Resources

Threading

Serialization

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

Runtime
InteropServices

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

CLR
Versions and SxS Execution
In-process side by side is the ability to run multiple versions of the CLR in a single process.

In-process side by side is the ability to run multiple versions of the CLR in a single process.
By
By default,
default, managed
managed COM
COM components
components run
run with
with the
the .NET
.NET Framework
Framework version
version they
they were
were buil
buil
regardless
of
the
.NET
Framework
version
that
is
loaded
for
the
process.
regardless of the .NET Framework version that is loaded for the process.

Side By Side Execution Allows multiple


versions of the Framework to be
installed on a single system
FCL 3.5
FCL 3.0

FCL 1.0

FCL 1.1

CLR 1.0
2002

CLR 1.1
2003

FCL 4.0

FCL 4.5

FCL 2.0

CLR 2.0
2005

CLR 4.0
2010

CLR 4.5
2012

4.0 onwards Supports


inproc SxS
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

The .NET Framework is an


execution and development
platform for building apps for
Windows, Windows Phone,
Windows Server, and Windows
Azure...
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Once a new technology


starts rolling, if you're not
part of the steamroller,
you're part of the road.

--Stewart Brand

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

"Give a person a fish and


feed them for a day; teach
person to use the Internet
they won't bother you
weeks.

you
that
and
for

--unknown
Ali Mirza | Department of Computer
Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Resources
http://msdn.microsoft.com/en-us/library/vstudio/w
0x726c2.aspx
Beginning Visual C# 2012 programming (Wrox)
Professional C# 2012 and .NET 4.5 (Wrox)
Pro C# 5.0 and the .NET 4.5 Framework, 6th Edition

Ali Mirza | Department of Computer


Science Bahria University,
Islamabad

SEN 442 Visual


Programming
Introduction to .NET. 2
Framework

Anda mungkin juga menyukai