1. .NET Architecture

31
1. .NET Architecture Based on slides by Joe Hummel

description

1. .NET Architecture. Based on slides by Joe Hummel. Aim. - PowerPoint PPT Presentation

Transcript of 1. .NET Architecture

Page 1: 1.  .NET Architecture

1. .NET Architecture

Based on slides by Joe Hummel

Page 2: 1.  .NET Architecture

2UCN Technology: Computer Science - 2012

Aim

“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 design• Component-based development

Page 3: 1.  .NET Architecture

3UCN Technology: Computer Science - 2012

Part 1

• CLR-based execution…

Page 4: 1.  .NET Architecture

4UCN Technology: Computer Science - 2012

Inspiration

• .NET is inspired by a number of elements

.NET

OOP JVM

GUIWeb

component-based design n-tier design

Page 5: 1.  .NET Architecture

5UCN Technology: Computer Science - 2012

.NET supports a number of languages

• .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.  .NET Architecture

6UCN Technology: Computer Science - 2012

.NET is “platform independent”

• Compiled .NET applications run on all supported platforms:

APP.exe

?Win64 Win32

(XP,2K,98)Windows Phone

CIL: Common Intermediate

Language

Page 7: 1.  .NET Architecture

7UCN Technology: Computer Science - 2012

CLR-based execution

• .NET applications are not stand-alone .exe-programs

APP.exe

other FCL components

CLR

JIT Compiler

obj code

OS Process

Underlying OS and HW

Core FCLCompare

to Java JVM

View the CIL Code

(“byte code”): ILDASM

Page 8: 1.  .NET Architecture

8UCN Technology: Computer Science - 2012

Java Virtual Machine

Execution of Java programs

source(xxx.java)

compiler

CPU

bytecode(xxx.class)

Interpreterfortolker

Page 9: 1.  .NET Architecture

9UCN Technology: Computer Science - 2012

CLR-based execution implies:• Clients need CLR & core FCL to run .NET apps

– Obtained through Redistributable .NET Framework– Runs on Windows 98 and higher, NT (sp6a) and higher– Runtime is integrated in Windows Vista, Windows 7,

Windows 8 and Windows Phone 7+.• Design issues…

+ managed execution (memory protection, etc.)+ portability:

• general assembly language• FCL = layer of abstraction between app and OS

– slower execution?• JIT compilation is expensive• But the JIT-compiler may take advantage of specific

target HW• pre-JIT is possible

Page 10: 1.  .NET Architecture

10UCN Technology: Computer Science - 2012

Part 2

• Application Design…

Page 11: 1.  .NET Architecture

11UCN Technology: Computer Science - 2012

• Often applications are designed as N "tiers"– good separation of responsibility– allows the same back-end tier for different clients

object

Application Design

Front-end

object

object

Business

Presentation Data Access Data

Page 12: 1.  .NET Architecture

12UCN Technology: Computer Science - 2012

Physical Design

• Where should tiers be physically deployed?– There are a range of different designs…

• Most common are:– locally– remote– web app– web service

Page 13: 1.  .NET Architecture

13UCN Technology: Computer Science - 2012

(1) Local Design• Local implies that tiers are all deployed on one local

computer– though may data be on a remote computer

FEobj obj

obj

• Pros? – Simple to develop!

• Cons? – Hard to deploy and maintain– Are to be installed and configured on every client

Page 14: 1.  .NET Architecture

14UCN Technology: Computer Science - 2012

(2) Remote Design• If Remote Design is used then the presentation (user

interface, front end) runs on a separate computer

FEobj obj

obj

• Pros? – Easier to maintain, back-end tiers May be updated without any

changes on the clients.– More secure, since the database only is accessed from the

server, and directly from the client.• Cons?

– Clients Must often use the same OS as the server; firewalls may cause troubles.

proprietary protocols

ServerClient

Page 15: 1.  .NET Architecture

15UCN Technology: Computer Science - 2012

(3) Web App Design

• In Web app presentation is generated by a Web server

obj obj

obj

Browser

ANY platform

Web server

• Pros?– scales to the internet, enhances the user group of the

applications.– No firewall problems (HTTP / port 80 communication only)

• Cons? – browser-based clients have limited functionality.

HTML / HTTP

WebPage

Server

Page 16: 1.  .NET Architecture

16UCN Technology: Computer Science - 2012

(4) Web Service Design

• Web services are objects that are available through Web technology

• In stead of HTML data is communicated in XML

obj obj

obj

custom FE

ANY platform

Server

Web server

XML / SOAP

obj

• Pros? – Open! Opens for integration of applications.

• Cons? – A technology under development…

other APP

ANY platform

Page 17: 1.  .NET Architecture

17UCN Technology: Computer Science - 2012

WCF – Window Communication Foundation

obj obj

obj

custom FE

ANY platform

Server

Web server

XML / SOAP / REST…And proprietary binary protocols

obj

other APP

ANY platform

• The new way of doing it: Supports • web-services (HTTP-based),• binary protocols (remoting) and• and much more (p2p, message queuing …)

Page 18: 1.  .NET Architecture

18UCN Technology: Computer Science - 2012

Part 3

• Component-based Development…

Page 19: 1.  .NET Architecture

19UCN Technology: Computer Science - 2012

Component-based Development

• Application tier is usually build from many components/classes/objects.

• E.g..:– A typical GUI application with local design has 3 components

packed as 1 EXE and 2 DLL

Front-end

object object

object

app.exebusiness.dll data.dll

Page 20: 1.  .NET Architecture

20UCN Technology: Computer Science - 2012

Assemblies• .NET packs components in what is known as assemblies• 1 assembly = 1 or more compiled classes

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

Development Tools

.EXE / .DLL

code.vbcode.vb

code.cs

assembly

Page 21: 1.  .NET Architecture

21UCN Technology: Computer Science - 2012

CLR-based execution revisited

• All assemblies must be present:

.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 22: 1.  .NET Architecture

22UCN Technology: Computer Science - 2012

Assembly – where are they?

• How does CLR find the needed assemblies?

• So far this is sufficient:– DLL-files must be in the same directory as the EXE– FCL assemblies are in GAC (Global Assembly Cache)– CLR starts looking in GAC, the in the directory of the EXE…

Page 23: 1.  .NET Architecture

23UCN Technology: Computer Science - 2012

GAC?

• GAC = Global Assembly Cache– C:\Windows or C:\WinNT katalog

• Observations:– Windows Explorer gives a flat view of GAC.– Command prompt gives the real view.– GAC may have different versions of same assembly.– Some assemblies are pre-JIT-compiled ("native image").– Hacker-proof by digital signature…

Page 24: 1.  .NET Architecture

24UCN Technology: Computer Science - 2012

Summing up

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

• Application design is typically multi-tier• Application design provides component-based development

– .NET components are packed as assemblies

Page 25: 1.  .NET Architecture

25UCN Technology: Computer Science - 2012

References

• Textbooks:– 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/

Page 26: 1.  .NET Architecture

2. .NET Development

Aim:

“Microsoft .NET development is based on an underlying framework of tools and classes. These tools and classes are known as the Framework SDK (Software Development Kit).”

Page 27: 1.  .NET Architecture

27UCN Technology: Computer Science - 2012

.NET Development

• 3 sets of tools for developing assemblies:

1) .NET Framework SDK• Free (100 MB)• complete set of command-line tools and documentation• Available for Windows NT, 2000, XP Pro, Vista and 7

• Other platforms?– Mac OS X via Rotor (i.e. SSCLI)– Linux (and Mac??) via Mono project

Page 28: 1.  .NET Architecture

28UCN Technology: Computer Science - 2012

.NET Development

2) Visual Studio .NET• Huge – available from eAcademy• Powerful integrated development environment (IDE)• One IDE for everything: GUI builder, database

connections, web-based, web service, DLLs, etc.• Used by 99% of the developers• $$

3) Free IDEs• Express Editions of Visual Studio• #develop, simplified clone of VS.NET• WebMatrix, for web-based applications

Page 29: 1.  .NET Architecture

29UCN Technology: Computer Science - 2012

Summing Up

• .NET is multi-language– SDK Framework based on C# and VB.NET– But many other languages are supported as well

• .NET-development is component-based– Auxiliary classes are implemented as one or more DLLs– .EXE is implemented using the DLLs.– if (assembly A is using a class from assembly B)

A must reference B!;

Page 30: 1.  .NET Architecture

30UCN Technology: Computer Science - 2012

References

• Textbooks:– Andrew Troelsen.: Pro C# 2010 and the .NET 4 Platform, 5th Ed.

(new edition is announced).– J. Richter, "Applied Microsoft .NET Framework Programming"

• Web sites:– http://msdn.microsoft.com/net– MSDNAA: http://www.msdnaa.net/– Mono: http://www.mono-project.com– Free IDEs:

• http://www.icsharpcode.net/OpenSource/SD/default.asp• http://www.asp.net/webmatrix/

Page 31: 1.  .NET Architecture

31UCN Technology: Computer Science - 2012

References

• More textbooks:– T. Archer and A. Whitechapel, "Inside C#" (2nd edition)– S. Lippman, "C# Primer"– J. Mayo, "C# Unleashed“– Anders Hejsberg, Mads Torgersen, Scott Wiltamuth, Peter

Golde: “The C# Programming Language”. Third Edition