Modern Execution in the 21st Century

Download Report

Transcript Modern Execution in the 21st Century

Program Execution in the
st
21 Century
Modern Software Development in .NET and C#
A webcast series for C++, Java, and VB6 developers – Part 1 of 15:
[ http://www.lakeforest.edu/~hummel/webcasts.htm ]
Joe Hummel, PhD
Software Architect, Author & Professor
Barracuda.NET:
[email protected]
Lake Forest College: [email protected]
1
"Modern Software Dev in .NET and C#"
A series for C++, Java, and VB6 developers
PPT-based lectures
Lab exercises — i.e. homework!
2
Date
Topic
1. Tues, March 1
2. Tues, March 15
3. Tues, March 22
4. Tues, March 29
.
.
.
Program Exec in the 21st Century
Classes, Components & Namespaces
Modern OO Programming in C#
Class Design for the .NET Framework
.
.
.
15. Tues, June 28
The Microsoft .NET Team System
Session Prerequisites
This is an intro of how .NET executes an app
Prereqs:
developer
object-based programming experience
Level 200
3
Today's objectives
“The days of compiling and linking a program to produce a
single native executable (.EXE) are coming to an end.
While program execution in Windows® has long been
DLL-based (dynamic linking), with .NET we are moving
towards a virtual machine model of execution…”
Topics:
Managed Execution
Component-Based Design
Deployment
4
Agenda
Managed Execution
Component-Based Design
Assembly Resolution
Deployment
5
Managed Execution
Idea:
modern software executes within run-time environment
why? portable and safer execution…
Your Application
Run-time Environment
Operating System
Hardware
6
Java
Based on run-time environment called JVM
JVM = Java Virtual Machine
JCL = Java Class Library
Java Application
7
JCL
JVM
JVM
JVM
JVM
Windows
Mac OS
Palm OS
…
x86
PPC
ARM
…
.NET
Based on CLR and FxCL
CLR = Common Language Runtime
FxCL = Framework Class Library
.NET Application
.NET Framework
Class Library
Common Language Runtime
Operating System
Hardware
8
Software Development in .NET
Pick your language and platform…
VB
C#
C++
J#
…
.NET Application
9
FxCL
CLR
CLR
CLR
CLR
CLR
Windows
Pocket PC
FreeBSD
Linux
…
x86
ARM
PPC
x86
…
Implications…
Your clients must have the .NET Framework
available via Redistributable .NET Framework (20MB)
3 versions: v1.0 (2002), v1.1 (2003), v2.0 (june 2005?)
Windows 2003 ships with v1.1
otherwise correct version must be installed
Design trade-off:
 portable
 safer execution (memory management, security, …)
 slower?
10
Managed code
C#, VB, J# compilers generate managed code
code that requires CLR to run & manage
C++ plays a dual role:
generates managed code (i.e. .NET dll/exe)
generates unmanaged code (i.e. native dll/exe)
common for OS work, legacy apps, etc.
11
CIL
CIL = Common Intermediate Language
CIL is the assembly language of the CLR
managed code == CIL code
// adds 2 integers together and returns the result…
public int Add(int x, int y)
{
return x + y;
}
C:\> ildasm app.exe
12
Agenda
Managed Execution
Component-Based Design
Assembly Resolution
Deployment
13
Apps are Component-Based
Apps consist of 1 or more components (DLLs)
Example:
typical n-tier design
object
object
Front-end
DB
object
GUI.exe
14
business.dll
data.dll
.NET is Component-Based
CLR = Common Language Runtime
FxCL = Framework Class Library
CLR and FxCL are components:
.DLL
.DLL
.EXE
Process
additional FxCL
components (DLLs)
JIT Compiler
obj code
CLR
(MSCOREE.dll)
15
Core
FxCL
(MSCOR
LIB.dll)
Underlying OS and HW
Assemblies
.NET components are called assemblies
Unit of deployment in .NET
1 assembly = 1 or more compiled source files
code.vb
code.vb
code.cs
Visual Studio .NET
assembly
16
.EXE / .DLL
Where are FxCL assemblies?
FxCL assemblies are stored in the GAC
GAC = Global Assembly Cache
Local
Shared
Version-aware
Secure
Tamper-proof
Some pre-JIT
17
Agenda
Managed Execution
Component-Based Design
Assembly Resolution
Deployment
18
Assembly Resolution
CLR must be able to locate correct assemblies
FxCL assemblies as well as our own assemblies
.DLL
.DLL
.EXE
Process
additional FxCL
components (DLLs)
JIT Compiler
obj code
CLR
19
Core
FxCL
Executive Summary…
Returning to the days of old, i.e. DOS-like
.NET applies a well-known search algorithm (like a path)
can customize search via .config file (like an .ini)
no use of registry!
20
Resolution Algorithm
1. .NET figures out what version is needed
2. .NET searches GAC (Global Assembly Cache)
3. If not found and .config file is present
then .NET searches where configured to
else
.NET searches directory containing .EXE
4. If not found
then application terminates with error
21
Typical n-tier app…
22
How does .NET know version, etc.?
Compiled into .DLL/.EXE as manifest
use ILDASM tool to peek inside assembly
ILDASM = Intermediate Language Disassembler
manifest reveals dependencies, versions, etc.
C:\> ildasm CustomerGUI.exe
23
Observations…
Manifest contains reference to assembly
name, version #, hash of public key token, etc.
Manifest does not contain:
code for assembly
registry information (no more GUIDs!)
location information (.NET uses search path)
24
Implications
No more registry!
.NET uses well-defined search path
No more DLL hell!
applications never use the wrong version
unless you say so via .config file
Config file hell?
machine config, user config, app config, etc.
25
How are assemblies referenced?
Tracked via References folder in VS project
You can add more:
26
Agenda
Managed Execution
Component-Based Design
Assembly Resolution
Deployment
27
Deployment Options
1. Install assemblies in same dir as .EXE

simplest, called xcopy deployment
2. Install some in .EXE dir, remainder in GAC

GAC allows you to share, install multiple versions
3. Custom deployment via .config file

allows custom location, e.g. on a server
4. "Zero-touch" deployment


28

clients install via URL: http://server/app/app.exe
app can update itself periodically
improved ClickOnce coming in VS 2005
Lots of deploymet details…
How do you write .config files?
How do you put something in the GAC?
Assign a version number?
Make an assembly tamper-proof?
Topics for webcast #11:
Tues, 31 May 2005
29
That’s it for today!
Thank you for participating
Next webcast:
30
Date
Topic
TODAY
Program Exec in the 21st Century
2. Tues, March 15
3. Tues, March 22
4. Tues, March 29
.
.
.
Classes, Components & Namespaces
Modern OO Programming in C#
Class Design for the .NET Framework
.
.
.
15. Tues, June 28
The Microsoft .NET Team System
Additional Resources
Web site for slides, demos, homework:
http://www.lakeforest.edu/~hummel/webcasts.htm
Resources:
J. Richter, "Applied Microsoft .NET Framework
Programming"
Rocky Lhotka, “Expert C# Business Objects”
Juval Löwy, “Programming .NET Components”
Zero-touch deployment:
http://msdn.microsoft.com/msdnmag/issues/04/05/clickonce/default.aspx
http://www.gotdotnet.com/team/windowsforms/appupdater.aspx
http://msdn.microsoft.com/msdnmag/issues/04/10/Bootstrapper/
http://msdn.microsoft.com/msdnmag/issues/02/07/NetSmartClients/default.aspx
31
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchnotouchdeploymentinnetframework.asp
32