Transcript Introducing the .NET Framework with C#
Slide 1
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 2
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 3
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 4
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 5
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 6
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 7
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 8
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 9
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 10
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 11
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 12
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 13
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 14
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 15
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 16
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 17
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 18
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 19
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 20
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 21
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 22
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 23
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 24
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 25
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 26
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 27
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 28
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 29
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 30
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 31
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 32
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 33
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 34
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 35
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 36
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 37
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 38
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 39
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 40
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 41
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 42
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 43
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 44
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 45
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 46
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 47
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 48
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 49
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 50
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 2
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 3
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 4
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 5
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 6
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 7
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 8
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 9
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 10
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 11
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 12
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 13
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 14
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 15
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 16
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 17
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 18
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 19
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 20
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 21
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 22
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 23
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 24
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 25
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 26
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 27
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 28
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 29
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 30
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 31
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 32
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 33
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 34
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 35
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 36
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 37
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 38
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 39
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 40
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 41
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 42
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 43
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 44
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 45
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 46
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 47
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 48
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 49
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team
Slide 50
.NET Session
Prepared By :
Manu Sharma
IBE Team
Topics
Types of .NET Applications
.NET Framework
CLR
Garbage Collection
Importance of .NET
.NET Applications
.NET Applications
Console Applications
GUI Applications
Windows Applications
Web
based Application
Library of Types
Windows
Services
Web Services
.NET Framework
.NET Architecture
VB.NET
C#
Web Forms
VC++.NET
VJ#
XML Web
Services
Windows
Forms
ASP.NET
.NET Framework Class Library
Common Language Runtime
Win 32
…..
Defining the .NET Framework
The .NET Framework is
A software
development environment
A runtime engine for Managed Code
A platform designed for Internet-Distributed
software
The .NET Framework is an exciting new
computing platform
Internet Distributed Software
Second-Tier
Second-Tier
(database or
other server)
Second-Tier
Web Server
Web Server
Client
Client
.NET Framework Features
Cross Language Compatibility
Platform Independent
CTS (Common Type Specification)
Cross Language Support
The .NET Framework supports many languages
Any compiler can be modified to emit managed
executables
Languages that target the .NET Framework
C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk
Dozens more existing and on the way
Regardless of source language, all managed code
can
IL and metadata
Use the same tools
Use the same reusable components
Take advantage of features of the CLR
Developers use their language of choice
Platform Independent Support
.NET Linux Development tool has been
created to date (Mono & DotGNU)
Mono
Primary Component is CLR which
executes .net Byte-code (MSIL)
Same as Java Runtime Environment.
DotGNU
More
.NET
Focused on Web Service area of
Common Type Specification
As .NET Application are converted into IL
prior to deployment and execution,thus all
primitive data types are represented as
.NET data type
VB.Net(Integer)=C#(int)=System.Int32(.NET Type)
Components
of
.NET Framework
CLR (Common Language Runtime)
FCL ( Framework Class Library)
Introducing the
Common Language
Runtime
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
The CLR and Managed Code
Managed Executable
Legacy
Software
(unmanaged code)
Reusable
Managed Components
Common Language Runtime
(JIT compilation, memory management, etc.)
Windows
(or other operating oystem)
What is Managed Code
Code that targets the CLR
C#,
VB.NET, PERL, Java, C++, Cobol, etc.
All Managed code has all features of CLR
Object
oriented
Internet oriented
Access to the Framework Class Library (FCL)
All Managed executables consist of
Intermediate
Metadata
Language (IL) instructions
IL and Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs
including
Classes definitions, field and method
definitions, parameter lists, return types, etc.
ILDasm.exe
Use ILDasm.exe to
view IL for managed
executable
Just-in-Time Compiling
All managed code runs in native machine
language
All managed code is made up of IL and
metadata
The CLR JIT-compiles the IL and metadata
At
execution time
Executed directly by CPU
Allows for the best of both worlds
Code
management features
Performance of full-speed execution
From Source Code to Managed .exe
SomeSource.cs
using System.Windows.Forms;
using System.Drawing;
class MyForm:Form{
public static void Main(){
Application.Run(
new MyForm());
}
protected override
void OnPaint(
PaintEventArgs e){
e.Graphics.DrawString(
"Hello World!",
new Font("Arial",35),
Brushes.Blue, 10,
100);
C# Compiler
SomeSources.exe
Metadata
A Managed
Application
IL
Executing a Managed Application
SomeSources.exe
Metadata
IL
At execution time the IL and
Metadata are JIT compiled
Running Process’ Memory
JIT Compiler
Native
Machine Language
10010100 10110000 10000000 10111010
11011011 11010111 11000010 01110110
The CPU executes the JITcompiled machine code directly
The Common Language Runtime
The Common Language Runtime (CLR)
Execution
engine of The .NET Framework
Offers many system services
Similar to an OS
Runs on a host OS
The .NET Framework
New
platform by Microsoft
Designed to target the Internet
The Purpose of the CLR…
Safe binary execution
Security,
memory protection
Running un-trusted code, locally
Performance and Functionality
Native
execution (JIT Compiled)
…The Purpose of the CLR
Bug reduction
More
code interacting, bugs affect more users
Ease of integration
Developer investment
Reuse
skills from project to project, even if the
projects are vastly different
Managed Code and the CLR
The Common Language Runtime (CLR) is a
runtime engine
Manages
.NET Code (such as C# applications)
Provides features such as memory management,
thread management, object type safety, security,
etc.
Is a part of the .NET Framework
Managed code
Code
that targets the CLR
Any .NET Language, including C#, Visual Basic,
C++, Java, Cobol, etc.
The CLR and Managed Code
IL and Metadata
All Managed executables consist of
Intermediate
Language (IL) instructions
Metadata
IL
CPU
independent machine language
Just-in-time compiled at runtime
Metadata
Structured
information
describes programming constructs including
Classes definitions, field and method definitions,
parameter lists, return types, etc.
Automatic Memory Management
The CLR manages memory for managed
code
All
allocations of objects and buffers made from a
Managed Heap
Unused objects and buffers are cleaned up
automatically through Garbage Collection
Some of the worst bugs in software
development are not possible with managed
code
Leaked
memory or objects
References to freed or non-existent objects
Reading of uninitialized variables
Pointerless environment
Garbage Collection
class MyClass{
void Method(){
Variable v1;
Variable v2;
The Managed Heap
B
do{
.
.
.
Objects A and D will
be cleaned up because
neither is directly or
indirectly referenced
by code
A
E
C
= Object or buffer in memory
D
Garbage Collection
Garbage collection occurs when a new
operation fails due to lack of memory
All managed threads are stopped
Collection starts with roots, and recursively finds
referenced objects
Roots
== globals, locals, cpu registers
Referenced objects are moved down in the
managed heap,
Making space available at the end
Removing unreachable objects
No
Fragmentation
References fixed-up and managed threads
restarted
Types of Managed Applications
Common application
GUI or windowed applications (Windows.Forms)
Console applications or command line apps
Web applications (ASP.net)
Web forms applications
Web services
Scripted code
Applications like word processors or database servers can host the CLR
Use any managed language (C#, VB, etc.) as a script or macro language
Wherever you use managed code
Same compilers and tools
Same FCL
Same CLR (JIT compiled, object oriented, memory managed, etc.
CLR Summary
The platform for managed code
C#,
VB.NET, etc.
Features
Memory
management, security management,
reflection, type safety
IL, metadata, JIT compilation
Assemblies, managed modules
Understanding the platform will make
coding .NET code easier
C#,
VB.NET, etc.
Introducing the
Framework Class
Library
The Framework Class Library
A huge collection of reusable types
Classes,
interfaces, enumerations and structures
For use by any managed code
Including
code written in any managed
programming language
Types for
Common
tasks such as collections, file IO,
memory and thread management
GUI and window manipulation
Web form and web service applications
Totally object oriented toolbox for developers
Ships
as part of the .NET Framework
Using the FCL
Types are arranged in a hierarchy of Namespaces
A type’s full name includes its namespaces
Form class is actually System.Windows.Forms.Form
Use using to indicate namespaces in source code
Assembly references are necessary for many types
The SDK documentation is critical for using SDK
types
Includes descriptions
Often includes useful code samples
Indicates namespaces and assemblies for types
Assembly vs. Managed Module
Deployment of managed code broken-up into to
logical concepts
Assembly
Managed module
Managed module
Single
physical file
Contains type definitions
Cannot be executed or used directly
Assembly
Unit
of versioning, deployment, and security
Can consist of multiple files
Managed modules
Resource files
Reasons for Assemblies
Decouple concepts of physical and logical
deployment
Logically,
you deploy a complete assembly
Physically, deploy only necessary files
Performance enhancement for network
deployment
Include resource files
No
embedding
Resource files retain their identity
Smiley.jpg, Info.xml, etc.
Versioning Assemblies
Assemblies can be strongly named
Includes
public/private key information
Strong named assemblies bind by version
Code
that uses V1 uses V1 even after V2 is
installed on the system
Avoids DLL hell
Gives you the freedom to make V2
components incompatible with V1
Strong binding is a major improvement
over DLLs
Top 10 Reasons
to Move to .NET
Reason 1
Standards integration
XML, SOAP, and more
In the past, the Microsoft
architecture has been built
on COM/DCOM, a binary
standard for allowing crossprocess communication that
standard didn't have any
relevance
outside
the
Microsoft world
ADO Recordset also saves
data in Binary Format and
Binary Format has no
meaning for non Microsoft
Environment.
.Net
uses
completely
standards-based like Xml
linked with XSD so that
client can validate the data.
SOAP is an XML-based
protocol that communicates
with Web services. The
integration of SOAP allows
for
easy
programmatic
access
by
any
client,
whether or not that client is
running
a
Microsoft
operating system.
Reason 2
Ease of Deployment
COM makes extensive use of
the Windows Registry to
locate components on the
machine. The concept was
good, but there would only
ever be a single instance of
a component registered, and
all applications would use
the same version. COM
promised to have new
versions
maintain
backwards
compatibility
with old versions, but
developers were free to
break this compatibility, and
sometimes did.
.Net doesn't use the registry,
most
deployments
can
simply be done with a copy
command. There's often no
need to develop installation
files. Also, Web applications
don't lock assemblies, so
you don't have to shut down
an application to update a
DLL.
Reason 3
Web service support
Microsoft is on the Web service bandwagon in a major way,
and it's never been easier to develop Web services than it is
with .Net. You can create simple Web services with Notepad
and not even have to run them through a compiler; simply
call them and .Net compiles them and even generates a test
page so you can verify they are working. .Net has all the
plumbing needed and generates all the files you need, such
as the WSDL file.
.Net is also a smart consumer of Web services: Once you set
a reference to a Web service, you treat it just like a local
assembly. You get full Intelligence and function completion
help.
Reason 4
Standard toolset for
any .Net language
User finally have an integrated set of tools for all your
languages like VB.NET,C# etc.
Reason 5
Support for mobile
devices
Soon after the release of Visual Studio .Net, Microsoft
released the Microsoft Mobile Internet Toolkit (MMIT) for
building mobile applications using .Net. This allows you to
visually drag and drop controls on forms aimed at mobile
devices. The toolkit handles writing the proper markup
language (e.g., WML, WAP, and so forth).
Coming soon will be the .Net Compact Framework, a scaleddown version of the Framework designed to run on Pocket
PC devices. This will enable developers to create rich
applications to run on Pocket PC computers.
Reason 6
Managed code
Reduces Bugs
Build More Scalable Applications
.Net handles
Allocating and recovering memory
Creating and destroying threads and processes
handling the access permissions of the running code.
Reason 7
Platform Independent
.NET Application can also be build and executed in other
platforms like LINUX
Reason 8
No lack of learning
resources
Net has probably spawned more books than any other
programming technology.
There are a number of Web sites that provide techniques
and tutorials for developers moving to .Net.
Reason 9
Modernized languages
Completely OOPS
The languages were built with an n-tier, component-based
approach in mind.
Reason 10
Standard base types across
languages
One of the banes of VB developers has been that a string in
VB was not the same as a string in C++, so when calling
Windows API functions, there could be some problems. .Net
specifies a standard definition for all types, so a string in
VB.Net is the same as a string in C#, which is the same as a
string in netCOBOL .Net.
THANKS
Prepared By :
Manu Sharma
IBE Team