Program Execution in the st 21 Century Modern

  • Slides: 32
Download presentation
Program Execution in the st 21 Century Modern Software Development in. NET and C#

Program Execution in the st 21 Century Modern Software Development in. NET and C# A webcast series for C++, Java, and VB 6 developers – Part 1 of 15: [ http: //www. lakeforest. edu/~hummel/webcasts. htm ] Joe Hummel, Ph. D Software Architect, Author & Professor Barracuda. NET: Lake Forest College: Joe. Hummel@Barracuda. net hummel@lakeforest. edu

"Modern Software Dev in. NET and C#" A series for C++, Java, and VB

"Modern Software Dev in. NET and C#" A series for C++, Java, and VB 6 developers PPT-based lectures Lab exercises — i. e. homework! Date Topic 1. Tues, March 1 2. Tues, March 15 Program Exec in the 21 st Century Classes, Components & Namespaces Modern OO Programming in C# Class Design for the. NET Framework. . . 3. Tues, March 22 4. Tues, March 29 2 . . .

Session Prerequisites This is an intro of how. NET executes an app Prereqs: developer

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

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

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…

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 = Java Virtual Machine JCL = Java

Java Based on run-time environment called JVM = Java Virtual Machine JCL = Java Class Library Java Application 7 JCL JVM JVM Windows Mac OS Palm OS … x 86 PPC ARM …

. NET Based on CLR and Fx. CL CLR = Common Language Runtime Fx.

. NET Based on CLR and Fx. CL CLR = Common Language Runtime Fx. CL = 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# …

Software Development in. NET Pick your language and platform… VB C# C++ J# … . NET Application 9 Fx. CL CLR CLR CLR Windows Pocket PC Free. BSD Linux … x 86 ARM PPC x 86 …

Implications… Your clients must have the. NET Framework available via Redistributable. NET Framework (20

Implications… Your clients must have the. NET Framework available via Redistributable. NET Framework (20 MB) 3 versions: v 1. 0 (2002), v 1. 1 (2003), v 2. 0 (june 2005? ) Windows 2003 ships with v 1. 1 otherwise correct version must be installed Design trade-off: C C D 10 portable safer execution (memory management, security, …) slower?

Managed code C#, VB, J# compilers generate managed code that requires CLR to run

Managed code C#, VB, J# compilers generate managed 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 = Common Intermediate Language CIL is the assembly language of the CLR managed

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

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

Apps are Component-Based Apps consist of 1 or more components (DLLs) Example: typical n-tier design object Front-end DB object GUI. exe 14 business. dll data. dll

. NET is Component-Based CLR = Common Language Runtime Fx. CL = Framework Class

. NET is Component-Based CLR = Common Language Runtime Fx. CL = Framework Class Library CLR and Fx. CL are components: . DLL . EXE Process additional Fx. CL components (DLLs) JIT Compiler obj code CLR (MSCOREE. dll) 15 Core Fx. CL (MSCOR LIB. dll) Underlying OS and HW

Assemblies. NET components are called assemblies Unit of deployment in. NET 1 assembly =

Assemblies. NET components are called assemblies Unit of deployment in. NET 1 assembly = 1 or more compiled source files code. vb code. cs Visual Studio. NET assembly 16 . EXE /. DLL

Where are Fx. CL assemblies? Fx. CL assemblies are stored in the GAC =

Where are Fx. CL assemblies? Fx. CL assemblies are stored in the 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

Agenda Managed Execution Component-Based Design Assembly Resolution Deployment 18

Assembly Resolution CLR must be able to locate correct assemblies Fx. CL assemblies as

Assembly Resolution CLR must be able to locate correct assemblies Fx. CL assemblies as well as our own assemblies. DLL . EXE Process additional Fx. CL components (DLLs) JIT Compiler obj code CLR 19 Core Fx. CL

Executive Summary… Returning to the days of old, i. e. DOS-like. NET applies a

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

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…

Typical n-tier app…

How does. NET know version, etc. ? Compiled into. DLL/. EXE as manifest use

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 Customer. GUI. exe 23

Observations… Manifest contains reference to assembly name, version #, hash of public key token,

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

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

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

Agenda Managed Execution Component-Based Design Assembly Resolution Deployment 27

Deployment Options 1. Install assemblies in same dir as. EXE u simplest, called xcopy

Deployment Options 1. Install assemblies in same dir as. EXE u simplest, called xcopy deployment 2. Install some in. EXE dir, remainder in GAC u GAC allows you to share, install multiple versions 3. Custom deployment via. config file u allows custom location, e. g. on a server 4. "Zero-touch" deployment clients install via URL: http: //server/app. exe u app can update itself periodically u 28

Lots of deploymet details… How do you write. config files? How do you put

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: Date Topic TODAY Program

That’s it for today! Thank you for participating Next webcast: Date Topic TODAY Program Exec in the 21 st Century 2. Tues, March 15 Classes, Components & Namespaces Modern OO Programming in C# Class Design for the. NET Framework. . . 3. Tues, March 22 4. Tues, March 29 30 . . .

Additional Resources Web site for slides, demos, homework: http: //www. lakeforest. edu/~hummel/webcasts. htm Resources:

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/Net. Smart. Clients/default. aspx 31 http: //msdn. microsoft. com/library/default. asp? url=/library/en-us/dv_vstechart/html/vbtchnotouchdeploymentinnetframework. asp

32

32