Sei sulla pagina 1di 24

Modern Software Development in .

NET and C#

<< >>

Session Prerequisites
This is an intro of how .NET executes an app Prereqs:
developer object-based programming experience

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
3

Agenda
Managed Execution Component-Based Design Assembly Resolution Deployment

Managed Execution
Idea:
modern software executes within run-time environment why? portable and safer execution

Your Application
Run-time Environment

Operating System
Hardware
5

Java
Based on run-time environment called JVM
JVM = Java Virtual Machine JCL = Java Class Library

Java Application
JVM
Windows x86
6

JCL

JVM
Mac OS PPC

JVM
Palm OS ARM

JVM

.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
7

Software Development in .NET


Pick your language and platform
VB C# C++ J#

.NET Application
CLR Windows x86
8

FxCL

CLR Pocket PC ARM

CLR FreeBSD PPC

CLR Linux x86

CLR

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?
9

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.

10

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

11

Agenda
Managed Execution Component-Based Design Assembly Resolution Deployment

12

Apps are Component-Based


Apps consist of 1 or more components (DLLs) Example:
typical n-tier design

object Front-end object

object

DB

GUI.exe
13

business.dll

data.dll

.NET is Component-Based
CLR and FxCL are components:
.EXE
.DLL .DLL Process

CLR = Common Language Runtime FxCL = Framework Class Library

JIT Compiler

additional FxCL components (DLLs)

obj code

Core FxCL
(MSCOR LIB.dll)

CLR
(MSCOREE.dll)

14

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

15

.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
16

Agenda
Managed Execution Component-Based Design Assembly Resolution Deployment

17

Assembly Resolution
CLR must be able to locate correct assemblies
FxCL assemblies as well as our own assemblies
.EXE
.DLL .DLL Process additional FxCL components (DLLs)

JIT Compiler

obj code

Core FxCL

CLR
18

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


19

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

20

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)

21

How are assemblies referenced?


Tracked via References folder in VS project You can add more:

22

Agenda
Managed Execution Component-Based Design Assembly Resolution Deployment

23

Thats it for today!


Thank you for participating

24

Potrebbero piacerti anche