Dot Net Over
-
Upload
rajanibtechcs-csi -
Category
Documents
-
view
27 -
download
2
Transcript of Dot Net Over
2
Session PrerequisitesSession Prerequisites
This is an This is an introintro of how .NET executes an of how .NET executes an appapp
Prereqs:Prereqs:developer developer
object-based programming experience object-based programming experience
3
Today's objectivesToday's objectives
““The days of compiling and linking a program to produce a The days of compiling and linking a program to produce a single native executable (.EXE) are coming to an end. single native executable (.EXE) are coming to an end. While program execution in WindowsWhile program execution in Windows®® has long been has long been DLL-based (dynamic linking), with .NET we are moving DLL-based (dynamic linking), with .NET we are moving towards a virtual machine model of execution…towards a virtual machine model of execution…””
Topics:Topics:Managed ExecutionManaged Execution
Component-Based DesignComponent-Based Design
Deployment Deployment
4
AgendaAgenda
Managed ExecutionManaged Execution
Component-Based DesignComponent-Based Design
Assembly ResolutionAssembly Resolution
DeploymentDeployment
5
Managed ExecutionManaged Execution
Idea:Idea:modern software executes within run-time modern software executes within run-time environmentenvironment
why? portable and safer execution…why? portable and safer execution…
HardwareHardware
Operating SystemOperating System
Run-time EnvironmentRun-time Environment
Your ApplicationYour Application
6
JavaJava
Based on run-time environment called Based on run-time environment called JVMJVM
JVM = Java Virtual MachineJVM = Java Virtual MachineJCL = Java Class LibraryJCL = Java Class Library
x86x86
WindowsWindows
JVMJVM
PPCPPC
Mac OSMac OS
JVMJVM
ARMARM
Palm OSPalm OS
JVMJVM
Java ApplicationJava Application
……
……
JVMJVM
JCLJCL
7
.NET.NET
Based on Based on CLRCLR and and FxCLFxCLCLR = Common Language RuntimeCLR = Common Language Runtime
FxCL = Framework Class LibraryFxCL = Framework Class Library
HardwareHardware
Operating SystemOperating System
Common Language RuntimeCommon Language Runtime
.NET Application.NET Application .NET Framework.NET FrameworkClass LibraryClass Library
8
Software Development in .NETSoftware Development in .NET
Pick your language and platform…Pick your language and platform…
x86x86
WindowsWindows
CLRCLR
ARMARM
Pocket PCPocket PC
CLRCLR
PPCPPC
FreeBSDFreeBSD
CLRCLR
x86x86
LinuxLinux
CLRCLR
……
……
CLRCLR
.NET Application.NET Application FxCLFxCL
VBVB C#C# C++C++ J#J# ……
9
Implications…Implications…
Your clients Your clients mustmust have the .NET have the .NET FrameworkFramework
available via available via Redistributable .NET FrameworkRedistributable .NET Framework (20MB) (20MB)
3 versions: v1.0 (2002), v1.1 (2003), v2.0 (june 3 versions: v1.0 (2002), v1.1 (2003), v2.0 (june 2005?)2005?)
Windows 2003 ships with v1.1Windows 2003 ships with v1.1
otherwise correct version must be installedotherwise correct version must be installed
Design trade-off:Design trade-off: portableportable safer execution (memory management, safer execution (memory management,
security, …)security, …) slower?slower?
10
Managed code Managed code
C#, VB, J# compilers generate C#, VB, J# compilers generate managedmanaged codecode
code that requires CLR to run & managecode that requires CLR to run & manage
C++ plays a dual role:C++ plays a dual role:generates generates managedmanaged code (i.e. .NET dll/exe) code (i.e. .NET dll/exe)
generates generates unmanagedunmanaged code (i.e. native code (i.e. native dll/exe)dll/exe)
common for OS work, legacy apps, etc.common for OS work, legacy apps, etc.
11
CILCIL
CIL = CIL = Common Intermediate LanguageCommon Intermediate LanguageCIL is the assembly language of the CLRCIL is the assembly language of the CLR
managed code == CIL codemanaged 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
AgendaAgenda
Managed ExecutionManaged Execution
Component-Based DesignComponent-Based Design
Assembly ResolutionAssembly Resolution
DeploymentDeployment
13
Apps are Component-BasedApps are Component-Based
Apps consist of 1 or more components Apps consist of 1 or more components (DLLs)(DLLs)
Example:Example:typical n-tier designtypical n-tier design
Front-end
object object
object
DB
GUI.exeGUI.exe business.dllbusiness.dll data.dlldata.dll
14
.NET is Component-Based.NET is Component-Based
CLR and FxCL are components:CLR and FxCL are components:
CLR = Common Language RuntimeFxCL = Framework Class Library
CLR (MSCOREE.dll)
CLR (MSCOREE.dll)
JIT Compiler
Process
Underlying OS and HW
Core FxCL
(MSCOR
LIB.dll)
Core FxCL
(MSCOR
LIB.dll)
.DLL.DLL.DLL.DLL.EXE.EXE
obj code
additional FxCL components (DLLs)
additional FxCL components (DLLs)
15
AssembliesAssemblies
.NET components are called .NET components are called assembliesassemblies
Unit of deployment in .NETUnit of deployment in .NET1 assembly = 1 or more compiled source files1 assembly = 1 or more compiled source files
Visual Studio .NET
.EXE / .DLL.EXE / .DLL
code.vbcode.vbcode.vbcode.vb
code.cscode.cs
assembly
16
Where are FxCL assemblies?Where are FxCL assemblies?
FxCL assemblies are stored in the GACFxCL assemblies are stored in the GACGAC = GAC = Global Assembly CacheGlobal Assembly Cache
LocalLocal
SharedShared
Version-awareVersion-aware
SecureSecure
Tamper-proofTamper-proof
Some pre-JITSome pre-JIT
17
AgendaAgenda
Managed ExecutionManaged Execution
Component-Based DesignComponent-Based Design
Assembly ResolutionAssembly Resolution
DeploymentDeployment
18
Assembly ResolutionAssembly Resolution
CLR must be able to locate correct CLR must be able to locate correct assembliesassemblies
FxCL assemblies as well as our own assembliesFxCL assemblies as well as our own assemblies
CLR CLR
JIT Compiler
Process
Core FxCL
Core FxCL
.DLL.DLL.DLL.DLL.EXE.EXE
obj code
additional FxCL components (DLLs)
additional FxCL components (DLLs)
19
Resolution AlgorithmResolution Algorithm
1.1. .NET figures out what version is needed.NET figures out what version is needed
2.2. .NET searches GAC (.NET searches GAC (Global Assembly Global Assembly CacheCache))
3.3. If not found and .config file is presentIf not found and .config file is present then .NET searches where then .NET searches where
configured toconfigured to elseelse
.NET searches directory .NET searches directory containing .EXEcontaining .EXE
4.4. If not foundIf not found then application terminates with then application terminates with errorerror
20
How does .NET know version, How does .NET know version, etc.?etc.?Compiled into .DLL/.EXE as Compiled into .DLL/.EXE as manifestmanifest
use use ILDASMILDASM tool to peek inside assembly tool to peek inside assemblyILDASM = ILDASM = Intermediate Language DisassemblerIntermediate Language Disassemblermanifest reveals dependencies, versions, etc.manifest reveals dependencies, versions, etc.
C:\> ildasm CustomerGUI.exe
21
Observations…Observations…
Manifest contains Manifest contains referencereference to assembly to assemblyname, version #, hash of public key token, etc.name, version #, hash of public key token, etc.
Manifest does Manifest does notnot contain: contain:code for assemblycode for assembly
registry information (no more GUIDs!)registry information (no more GUIDs!)
location information (.NET uses search path)location information (.NET uses search path)
22
How are assemblies referenced?How are assemblies referenced?
Tracked via Tracked via ReferencesReferences folder in VS folder in VS projectproject
You can add more:You can add more:
23
AgendaAgenda
Managed ExecutionManaged Execution
Component-Based DesignComponent-Based Design
Assembly ResolutionAssembly Resolution
DeploymentDeployment