20
1. The .NET Architecture

1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

Embed Size (px)

Citation preview

Page 1: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

1. The .NET Architecture

Page 2: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

2Microsoft

Objectives

“Microsoft .NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries (FCL). The CLR defines a common programming model and a standard type system for cross-platform, multi-language development.”

• CLR-based execution• Application designs

Page 3: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

3Microsoft

Part 1

• CLR-based execution…

Page 4: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

4Microsoft

Influences

• .NET is the result of many influences…

.NET

OOP JVM

GUIWeb

component-based design n-tier design

Page 5: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

5Microsoft

.NET is multi-language

• .NET supports VB, C# (C-sharp), C++, J# (Java 1.1), Eiffel, etc.

code.vb code.cs code.cpp ...

Development Tools

app.exe

FCL

Page 6: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

6Microsoft

.NET is cross-platform

• Compiled .NET apps run on any supported platform:

APP.exe

?Win64 Win32

(XP,2K,98)WinCE

Page 7: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

7Microsoft

How is cross-platform achieved?

• Cross-platform execution realized in two ways:

1. apps are written against Framework Class Library (FCL), not underlying OS

2. compilers generate generic assembly language which must be executed by the Common Language Runtime (CLR)

Page 8: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

8Microsoft

(1) FCL

• Framework Class Library– 1000's of predefined classes– common subset across all platforms & languages – networking, database access, XML processing, GUI, Web, etc.

• Goal?– FCL is a portable operating system

Page 9: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

9Microsoft

(2) CLR-based execution

• Common Language Runtime must be present to execute code:

APP.exe

other FCL components

CLR

JIT Compiler

obj code

OS Process

Underlying OS and HW

Core FCL

Page 10: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

10Microsoft

Implications of .NET's execution model

1. Clients need CLR & FCL to run .NET apps– available via Redistributable .NET Framework– 20MB download– runs on 98 and above, NT (sp6a) and above

2. Design trade-off…+ managed execution (memory protection, verifiable code, etc.)+ portability:– slower execution?

Page 11: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

11Microsoft

Part 2

• Application design…

Page 12: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

12Microsoft

Monolithic

• Monolithic app: all source code compiled into one .EXE

– *not* the norm on Windows…

APP.exe

Page 13: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

13Microsoft

Component-based

• Component-based app: .EXE + 1 or more .DLLs

– standard practice on Windows…

compute.dll

data.dll

GUI.exe

Page 14: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

14Microsoft

Why component-based?

• Many motivations:

– team programming

– multi-language development (I like VB, you like C#)

– code reuse (e.g. across different .EXEs)

– independent updating (update just component X)

• .NET offers good support for component-based design…

Page 15: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

15Microsoft

Assemblies

• .NET packages components into assemblies• 1 assembly = 1 or more compiled classes

– .EXE represents an assembly with classes + Main program– .DLL represents an assembly with classes

Development Tools

assembly

code.vbcode.vb

code.cs

.EXE / .DLL

Page 16: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

16Microsoft

CLR-based execution revisted

• CLR must be able to locate all assemblies:

.EXE

other FCL assemblies

CLR

JIT Compiler

obj code

OS Process

Underlying OS and HW

Core FCLassembly

.DLL.DLL

.DLL

obj codeobj code

obj code

Page 17: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

17Microsoft

Assembly resolution

• How does CLR find assemblies?

• For now, simple answer is sufficient:– our DLLs must reside in same directory as our EXE– FCL assemblies reside in GAC– CLR looks in GAC first, then EXE's directory…

Page 18: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

18Microsoft

GAC?

• 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…

Page 19: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

19Microsoft

Summary

• .NET architecture is:– multi-language– cross-platform– based on the CLR, FCL, and JIT technology

• Application designs are typically multi-tier• Application designs yield component-based development

– .NET components are packaged as assemblies

Page 20: 1. The.NET Architecture. 2 Microsoft Objectives “Microsoft.NET is based on the Common Language Runtime (CLR) and an extensive set of Framework Class Libraries

20Microsoft

References

• Books:– J. Richter, "Applied Microsoft .NET Framework Programming"– T. Thai and H. Lam, ".NET Framework Essentials"

• Web sites:– http://msdn.microsoft.com/net– http://www.gotdotnet.com/– Linux port (Mono): http://www.go-mono.com/– MS source (Rotor / SSCLI): http://msdn.microsoft.com/net/sscli