Title: Lecture 1: The 'NET Architecture
1Lecture 1The .NET Architecture
2Example a "real world" application
- Here's a common application design in industry
Data Access
Business
Presentation
DB
Server
Server
Host Process
DB
Web Server
Browser Client
Web Page
Generic Client
Server
DB
GUI Client
3Objectives
- Microsoft .NET is based on the .NET Framework,
which consists of two major components the
Common Language Runtime (CLR) and an extensive
set of Framework Class Libraries (FxCL). The CLR
defines a common programming model and a standard
type system for cross-platform, multi-language
development. - The CLR is analogous to the Java JVM for running
programs. - Managed execution
- Application designs
- .NET execution model
4Part 1
5Influences
- .NET is the result of many influences
OOP
JVM
GUI
.NET
Web
component-based design
n-tier design
6Program execution in the 21st century
- Idea
- modern software executes using a run-time
environment - why? portable and safe execution
Your Application
Run-time Environment
Operating System
Hardware
7Portable and Safe Execution
- Why portable?
- Because application can run anywhere the Run-time
environment exists (PC, Mac, Linux, Palm Pilot,
etc.) - Why safe?
- Because Run-Time environment can prevent
application from accessing memory, hard disk,
files, etc. - The run-time environment is typically referred to
as a "Virtual Machine" (VM), since it behaves
like a real machine (executing applications) but
isn't actually real
8Program execution in .NET
- Based on Common Language Runtime .NET Framework
Class Library (.NET is these two things) - run-time environment large software library
Your Application
.NET FrameworkClass Library
Common Language Runtime (CLR)
OS
Hardware
9Program execution in .NET
- Every .NET program you write executes in the CLR.
- Every .NET program you write can take advantage
of the .NET Framework Class Library, a huge
library containing 1000's of prebuilt software
modules. - Note that Java programs execute exactly the same
way, in a run-time environment called the Java
Virtual Machine (JVM) with a large class library.
10So what is .NET?
- A technology for developing executing software
- language independent
- platform independent
VB
J
C
C
Your Application
.NET FrameworkClass Library
Common Language Runtime (CLR)
Windows / Linux /
Pentium / PowerPC /
11So what is .NET?
- VB Visual Basic
- J J-sharp Java on the .NET platform
- J Java Syntax Java Class Libraries V 1.1.8
Swing Data Structures Some of V1.2 - J is not industry-strength Java, but is
sufficient for teaching Computer Science - C C-sharp
- Can mix and match languages within applications
- C
- Works within the CLR, or
- Can generate native code (machine language)
- Only .NET language which can generate native code
12.NET is platform independent?
- Compiled .NET apps run on any supported platform
APP.exe
?
Win64
Win32 (XP,2K,98)
Pocket PC
13.NET is platform independent?
- Other platforms? As of June 2003
- Mono open-source Linux port of .Net, beta, most
of .NET except support for GUI, which is still in
progress. - Rotor MS has released the source to the
standardized components of .Net, compiles on
Windows, FreeBSD, and Mac OS X. 1.0 Release, C
only, no GUI support. - dotGNU GNU is working on a .NET release for
Unix. - Mono can be downloaded from http//www.go-mono.com
/ - Rotor, officially known as SSCLI, can be
downloaded from http//msdn.microsoft.com/net/sscl
i - For dotGNU, see http//www.dotgnu.org/
14.NET uses JIT compilation
- .NET guarantees just-in-time compilation to
native code
APP.exe
OS Process
CLR
other FxCL components
Core FxCL
obj code
Underlying OS and HW
15.NET uses JIT compilation
- JIT Just-in-time, which gets its name because
you generate the actual x86 code at the last
possible moment, i.e. run-time. - Java uses a similar approach, though JIT
compilation is typically delayed until the code
is executed a number of times to make JIT
compilation worthwhile. - Obj_code is thrown away when the application
stops running, no .exe file is saved like in
traditional languages - No .exe file can be saved unless you have a
separate tool called NGEN (native generation) for
a particular architecture - JIT compiling adds about 10 execution time
overhead
16Implications of .NET's execution model
- Clients need CLR FxCL to run .NET apps (must be
installed on each client) - available via Redistributable .NET Framework
- 20MB download available from Windows Update
- runs on 98 and above, NT (sp6a) and above
- Visual Studio installs everything you need
- In Windows 2003, the CLR and FxCL are already
installed by the operating system - Design trade-off
- managed execution (memory protection, verifiable
code, etc.) - portability
- slower execution? 10 or so
17Part 2
18Monolithic
- Monolithic app all source code compiled into
one .EXE - not the norm on Windows
compute.cs
main.cs
data.cs
APP.exe
19Component-based
- Component-based app .EXE 1 or more .DLLs
(Dynamic Link Libraries) - standard practice on Windows
compute.cs
main.cs
compute.dll
GUI.exe
data.cs
data.dll
20Component-based
- Applications are built in small pieces
- The pieces dont get executed until they are
called - The pieces get JIT compiled when they are called
the first time by the application
21Why component-based?
- Many motivations
- team programming
- multi-language development (I like VB, you like
C) - code reuse (e.g. across different .EXEs)
- independent updating (can update just component
X) - FxCL ships as a set of components!
22Example n-tier design
- Many applications are designed with N levels or
"tiers" - good separation of concerns
- enables reuse of back-end tiers across varying
FEs
Front-end
Business
Presentation
Data Access
Data
23Part 3
24Assemblies
- .NET packages components into assemblies
- 1 assembly 1 or more compiled classes
- .EXE represents an assembly with classes Main
program (an execution file) - .DLL represents an assembly with classes (a
component)
code.vb
code.vb
code.cs
Development Tools
.EXE / .DLL
assembly
25CLR-based execution revisted
- CLR must be able to locate all assemblies
.DLL
.DLL
.EXE
.DLL
OS Process
CLR
other FxCL assemblies
Core FxCL assembly
obj code
obj code
obj code
obj code
Underlying OS and HW
26Assembly resolution
- How does CLR find assemblies?
- Windows currently uses a database called the
"registry" - the registry is gone in .NET
- In a way, we are returning to days of old (i.e.
DOS) - CLR applies a well-known search algorithm
- customize search via .config (".ini") files
- For now, we'll assume simplified search
algorithm - our DLLs must reside in same directory as our EXE
- FxCL assemblies reside in GAC (Global Assembly
Cache) - CLR looks in GAC first, then EXE's directory
- A file in the GAC can override a local copy with
the same name
27GAC?
- GAC Global Assembly Cache
- C\Windows or C\WinNT directory
- Observations
- explorer yields a flat view of GAC
- command-shell yields actual representation
- GAC can hold different versions of the same
assembly - some assemblies have been pre-JIT ("native
image") - tamper proof via digital signatures
28Summary
- .NET architecture is
- multi-language
- cross-platform
- based on the VM JIT technology
- Application designs are typically multi-tier
- Application designs yield component-based
development - .NET components are packaged as assemblies
29Resources
- Books
- J. Richter, "Applied Microsoft .NET Framework
Programming" (C) - J. Richter and F. Balena, "Applied Microsoft .NET
Framework Programming in Microsoft Visual Basic
.NET" (VB) - T. Thai and H. Lam, ".NET Framework Essentials"
- Web sites
- http//msdn.microsoft.com/net
- http//www.gotdotnet.com/
30(No Transcript)