47
1 Im Überblick Bearbeitet von Nicola Almukarker 03.02.2004

1 Im Überblick Bearbeitet von Nicola Almukarker 03.02.2004

Embed Size (px)

Citation preview

1

Im Überblick

Bearbeitet von Nicola Almukarker

03.02.2004

2

Table of contents (1)

• „What is .NET?“– .Net Framework

• Common Language Runtime (CLR)

• Base Class Library (BCL)

– what does .net bring?

3

Table of contents (2)

• .Net Architecture– virtual machine – Common Type System (CTS)– Common Language Specification (CLS)– Common Intermediate Language (CIL)– Codemanagement– Assemblies and modules– Security

4

Table of contents (3)

• ASP.NET– Production of dynamic web sites

• Web-Services– Overlook

• Summary

5

What is .NET? (1)

• Operating System?

• Server?

• Software product, Compiler?

• Programming Language?

• Protocols and technologies for the communication between server and clients?

6

What is .NET? (2)Anwendung

Operating system

Base Class Library

ASP.NET ADO.NET Web-Services ...

Common Language Runtime

Garbage Collection

Security Just-in-TimeCompilation ...

7

What is .NET? (3) Base Class Library

8

What is .NET? (4)

• what does .net bring?– Robust software and Security

• Verification of the CIL-Code

• Security through Garbage Collector

– Simple installation and deinstallation • Assemblies in own Directory or GAC

• No need to register in the Windows-Registry

– Uniform software for desktop and web

9

What is .NET? (5)

Windows API

ASPMFC & ATLVB Forms

.NET Framework

10

Agenda

• „What is .NET?“• .Net Architecture

– virtual machine

– Common Type System (CTS)

– Common Language Specification (CLS)

– Common Intermediate Language (CIL)

– Meta data

– Assemblies and modules

– Security

11

Virtual machine (1)

• A virtual machine for what?– SW-Procssor (Stackmachine)

• reading and saving Operands & Operations

• It works on IL-code and not native code

– Platform and language independence

C# VB.NET Oberon Eiffel

Windows Linux PalmOS MacOS

n*m

12

Virtual machine (2)

– Compactness by IL-code instructions– Optimized code by analyze the Operating

system’s configuration

C# VB.NET Oberon Eiffel

IL-Code

MacOSPalmOSLinuxWindows

Frontends

Backends

n+m

13

Virtual machine (3)

• CLR is the successor of COM

Typesystem

Services for Distributedapplications

Loader Remoting

Laguage-layer

COM Runtime

MicrosoftTransaction

Server

Laguage-layer

COM+Runtime

CommonLanguage Runtime

14

Common Type System (CTS) (1)

Integers

Bool values

Floating point num.

Typed Reference

Strings

Arrays

Methods-

unmanaged

Managed

Pointers

Value Types Reference Types

Structs

Enumerations

Interfaces

Classes

Delegates

Boxing

15

Common Type System (CTS) (2)

x

y

y

x

x

MethodState

MethodState

Heap

Heap

.y VPoint

RPoint

Method execute

End of Method

16

Common Type System (CTS) (3)

• Boxing & Unboxing (Example in C#)object obj = 3 ; // Boxing

int x = (int) obj ; // Unboxing

.locals ( object obj, int32 x )

// object obj = 3 ;

1 ldc.i4.3

2 box System.Int32

3 stloc obj

// int x = (int) obj ;4 ldloc obj5 unbox System.Int326 ldind.i47 stloc x

17

Common Type System (CTS) (4)

Boxing & Unboxing

3

Heap MethodState

Obj

xStack

Obj

xStack

Obj

xStack

Obj

xStack

Obj

xStack

Obj

xStack

Obj

xStack

3 3

33

33

..

.

.. .

33

.

1

74

32

65

18

Common Type System (CTS) (5)• Predefined data types of the CLR

IL-Assembler CLR-name Descriptionbool System.Boolean 1 Byte: 1-255 (true)char System.Char 16-Bit-Unicode-signstring System.String Unicode-Stringobject System.Object managed Pointer on obj. typedref System.Typed- value type (Pointer and

Reference type-Info for vararg)float32 System.Single 32 Bit numbers float64 System.Double 64 Bit numbersint8 System.Sbyte 8 Bit: [-128..127]int16 System.Int16 16 Bit: [-32768..32767]

19

Common Type System (CTS) (6)• Call of a method with variable number of

parameters .method static vararg void VarArgMethod(int32 x) {...}

Call vararg void A::VarArgMethod(int32, ..., int32, string)

ldc.i4.1ldc.i4.2Ldstr“Hello!“

- the Iterator system is effective on the further Parameteren in the trunk of the method

20

Common Type System (CTS) (7).locals init (valuetype System.ArgIterator iter)

//The Iterator is laid out to this in a local variable on the stackldloca iterarglistcall instance void System.ArgIterator::.ctor(valuetype

System.RuntimeArgumentHandle)

// arglist produces a reference on the list of the optional //parameters which is submitted with the constructor of the Iteratorsldloca itercall instance typedref System.ArgIterator::GetNextArg()call object System.TypedReference::ToObject(typedref)

21

Common Language Specification (CLS) (1)

CLS

CTS

Language B

Language A

Language C

22

Common Language Specification (CLS) (2)

• CLSCompliant: Attribute checks the CLS-conformity of the Assemblies

• an Assembly must explicitly be conformed

Error CS3002: Return type of 'VisibleType.Accessible()' is not CLS-compliant

Using System;[assembly: CLSCompliant(true)]Public class VisibleType{

public sbyte Accessible(){...}}

[CLSCompliant(false)]public sbyte Accessible(){...}

23

Common Intermediate Language (CLS) (3)

• Operand’s Type-infromation in Java-Bytecode & CIL (Example) Save the sum of the first 2 local variables in a

third one

J-Bytecode (Integer) J-Bytecode (Float) CIL (Integer or Float)

iload_0 fload_0 ldloc.0iload_1 fload_1 ldloc.1iadd fadd addistore_2 fstore_2 stloc.2

24

Just in time Compilation (1)

VB.Net C++C#

Compiler Compiler Compiler

IL-Code

ASM Code

JIT CompilerCLR

Operating system

25

Just in time Compilation (2)

Class A

Method 1 (ASM)

Method 2 (IL)

Method 3 (IL)

Method 4 (IL)

(1) Method call

Class B

Methode 1 (IL)

Method 2 (IL)

JIT Compiler(2) Replacing IL

code by native code

Method 1 (ASM)

26

Codemanagement (1)• Memory administration

Execution Engine (EE) Thread 1 Thread 2 Thread 3 ...

List the method conditions

HeapList the method conditions

.

.

.

27

Codemanagement (2)

– Method conditions

Safety featuresMethod description

arguments

Local variables

Local allocations

Previouscondition

Instructionpointer

Operands stack and output parameters

28

Codemanagement (3)• Garbage Collector

Laying out objects onthe Heap

NextObjPtr

newobj A::.ctor() newobj B::.ctor()

Obj A Obj A

Obj B

NextObjPtr

Roo

ts

Roo

ts

Obj A

Obj B

Obj C

Obj D

Obj FObj E

Obj A

Obj D

Obj E

NextObjPtr

GC

Heap and Indicatorbefore and after a GC

29

Assemblies and modules (1)

• Meta data in PE-Files

PE/COFFHeaders

CLRHeader

CLR DataMeta data IL-Code.Net-PE-File

1. a program which informs the user that this file isn't executable under DOS2. CLR header saves version number of the CLR for which the program was written

30

Assemblies and modules (2)

• Module (managed module): .net-PE file is a module which contains the definition of types with Metadaten, the CIL code of the defined methods and a Manifest.

• Manifest is in an exe file and has all information which is necessary to find all definitions of an Assembly.

• Assembly manifest references files

31

Assemblies and modules (3)• Assembly is a .Net-Component that Capsules,

secures and versions modules

Manifest.assembly OtherApp

Meta data.assmbly extern mscorlib.assmbly extern MFAApp

.class public App

CIL-Code

.module AnotherAppManifest

.module MFAApp

.assemblyMFAApp

.file pub.mod

.class extern public PublicType

Meta data.assmbly extern mscorlib.modul extern pub.mod.class public App

CIL-Code

.module pub.mod

Meta data.assmbly extern mscorlib.class public PublicType

OtherApp.exe

MFAApp.exepub.mod

CIL-Code

Aim: PublicType

32

Assemblies and modules (4)

• Version– Private Assemblies (in Application‘s directory)– Shared Assemblies (Global Assembly Cache)

• StrongName: name of the Manifest module

• Version: Major.Minor.Build.Revision

• Culture

• Public key 128 Byte to identify the producer

33

Assemblies and modules (5)

• Producing of version– In source code with the attribute

System.Reflection.AssemblyVersionAttribute– By Assembly-Linker(al.exe) at the production of the

Assembly – Examples

Input value result1. 1.2.3.4 1.2.3.4 2. - 0.0.0.03. 1.2.* 1.2.745.18000 (on 15.1.2002 at 10:00:00 h)

34

Assemblies and modules (6)• Roll based security

• code based security– fixing the access rights of an assembley to the

load time – Security stack walk

Assembly A

Security Manager

Assembly A

EvidenceZone

Hash

StrongName

Site...

EnterpriseMachine

UserApplication Domain

Policy Levels

PermissionSet

FileIO

ReflectionIsolatedStorage

Registry

...

35

Assemblies and modules (7)

– Security stack walk

Assembly A

Assembly B

Assembly C

Assembly D

Ressource

p.Demand()

36

ASP.NET (1)

• Technology for web applications – Web Forms and dynamic web pages by servers

scripts– object orientation (aspx-page)– Web controls: GUI-objects– separation from layout and application logic

(.aspx and source code .cs)

37

ASP.NET (2)

– component orientation (events)– Interactive lay-out of web pages– Compilation instead of interpretation– Improve administration of the page condition,

• Dynamic ASPX Page– Simple example: a page with visitor counter

38

Using System.IO;Public class CounterPage : System.Web.UI.Page{ int CounterValue(){ FileStream s; s=new FileStream("c:\\Data\\Counter.dat", FileMode.OpenOrCreate); int n; try{

BinaryReader r = new BinaryReader(s);n = r.ReadInt32();

} catch { n = 0;}n++;s.Seek(0,SeekOrigin.Begin);BinaryWriter w = new BinaryWriter(s);w.Write(n);s.Close(); return n;

}}

CounterPage.cs

ASP.NET (3)

39

<% @ Page Language="C#" Inherits="CounterPage" Src="CounterPage.cs" %>

<html> <head> <title>Besucherz&auml;hler</title></head> <body> <h1>Willkommen</h1> Sie sind der <%=CounterValue()%>. Besucher Dieser Seite! </body></html>

Counter.aspx

ASP.NET (4)

40

ASP.NET (5)

Client(Web-Browser)

Server(IIS)

ASP.NET Counter.aspx

Counter.dat

.NET Framework

RequestCounter.aspx

Response*.html

41

Web-Sevices (1)

• heterogeneous distributed services• they are independent of the operating system,

Programming language and binary transfer protocol

• XML based protocol [SOAP]• [WSDL] earlier IDL of DCOM• IIS passes on soap calls to the corresponding web-

service-implementation, produces objects and/or deletes them

42

Web-Sevices (2)

BookParadise

Web-Service A

Web-Service B

UDDI2. search

3. Connection

4. Get data

1. Registering

43

Web-Sevices (3)

• My Services: Address book, calendar, mailbox, ...

• Microsoft .Net Alerts-Services for PC, Smart devices etc...

• Transfer via Binary protokol with sockets or .Net Remoting and not TCP/IP (limited)

44

Web-Sevices (4)

• Namespaces for Web-Services– System.Web.Services (creates web services)– System.Web.Services.Configuration

(configures xml description)– System.Web.Services.Description (classes

for WSDL)– System.Web.Services.Discovery– System.Web.Services.Protokols

45

Summary (1)

• „What is .NET?“

• virtual machine

• Common Type System (CTS)

• Common Language Specification (CLS)

• Common Intermediate Language (CIL)

• Codemanagement

46

Summary (2)

• Assemblies and modules

• Security

• ASP.NET– Production of dynamic web sites

• Web-Services– heterogeneous distributed services

47

Danke für die Aufmerksamkeit!