Table of contents

Download Report

Transcript Table of contents

Im Überblick
Bearbeitet von Nicola Almukarker
03.02.2004
1
Table of contents (1)
• „What is .NET?“
– .Net Framework
• Common Language Runtime (CLR)
• Base Class Library (BCL)
– what does .net bring?
2
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
3
Table of contents (3)
• ASP.NET
– Production of dynamic web sites
• Web-Services
– Overlook
• Summary
4
What is .NET? (1)
•
•
•
•
•
Operating System?
Server?
Software product, Compiler?
Programming Language?
Protocols and technologies for the
communication between server and clients?
5
What is .NET? (2)
Anwendung
Base Class Library
ASP.NET
ADO.NET
Web-Services
Garbage
Collection
Common Language Runtime
Just-in-Time
Security
Compilation
...
...
Operating system
6
What is .NET? (3)
Base Class Library
7
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
8
What is .NET? (5)
.NET Framework
VB Forms
MFC & ATL
ASP
Windows API
9
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
10
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
n
*
m
C#
VB.NET
Oberon
Eiffel
Windows
Linux
PalmOS
MacOS
11
Virtual machine (2)
C#
n
+
m
VB.NET
Oberon
Eiffel
Frontends
IL-Code
Windows
Linux
PalmOS
Backends
MacOS
– Compactness by IL-code instructions
– Optimized code by analyze the Operating
system’s configuration
12
Virtual machine (3)
• CLR is the successor of COM
Typesystem
Laguage-layer
Services for
Distributed
applications
Microsoft
Transaction
Server
Loader
Remoting
Laguage-layer
COM+
Runtime
Common
Language
Runtime
COM Runtime
13
Common Type System (CTS) (1)
Value Types
Integers
Floating point num.
Bool values
Strings
Typed Reference
Structs
Enumerations
Boxing
Reference Types
Pointers
Managed
unmanaged
Methods-
Interfaces
Classes
Arrays
Delegates
14
Common Type System (CTS) (2)
MethodState
.
Heap
x
y
Method execute
x
y
VPoint
MethodState
Heap
End of Method
RPoint
x
y
15
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
4
5
6
7
// int x = (int) obj ;
ldloc obj
unbox System.Int32
ldind.i4
stloc x
16
Common Type System (CTS) (4)
Boxing & Unboxing
Heap MethodState
Obj
1
Obj
2
3
x
3
3
4
.
.
Stack
.
Obj
x
3
Stack
.
x
3
3
Stack
.
Obj
x
3
3 Stack
6
Obj
x
Stack
Obj
Stack
5
3
.
x
.
Obj
3 x
Stack
7
17
Common Type System (CTS) (5)
• Predefined data types of the CLR
IL-Assembler
bool
char
string
object
typedref
float32
float64
int8
int16
CLR-name
System.Boolean
System.Char
System.String
System.Object
System.TypedReference
System.Single
System.Double
System.Sbyte
System.Int16
Description
1 Byte: 1-255 (true)
16-Bit-Unicode-sign
Unicode-String
managed Pointer on obj.
value type (Pointer and
type-Info for vararg)
32 Bit numbers
64 Bit numbers
8 Bit: [-128..127]
16 Bit: [-32768..32767] 18
Common Type System (CTS) (6)
• Call of a method with variable number of
parameters
.method static vararg void VarArgMethod(int32 x) {...}
ldc.i4.1
ldc.i4.2
Ldstr“Hello!“
Call vararg void A::VarArgMethod(int32, ..., int32, string)
- the Iterator system is effective on the further Parameteren
in the trunk of the method
19
Common Type System (CTS) (7)
.locals init (valuetype System.ArgIterator iter)
//The Iterator is laid out to this in a local variable on the stack
ldloca iter
arglist
call 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 Iterators
ldloca iter
call instance typedref System.ArgIterator::GetNextArg()
call object System.TypedReference::ToObject(typedref)
20
Common Language Specification
(CLS) (1)
Language A
Language B
CTS
CLS
Language C
21
Common Language Specification
(CLS) (2)
• CLSCompliant: Attribute checks the CLSconformity of the Assemblies
• an Assembly must explicitly be conformed
Using System;
[assembly: CLSCompliant(true)]
Public class VisibleType{
public sbyte Accessible(){...}
}
 Error CS3002: Return type of 'VisibleType.Accessible()' is not
CLS-compliant
[CLSCompliant(false)]
public sbyte Accessible(){...}
22
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)
iload_0
iload_1
iadd
istore_2
J-Bytecode (Float)
fload_0
fload_1
fadd
fstore_2
CIL (Integer or Float)
ldloc.0
ldloc.1
add
stloc.2
23
Just in time Compilation (1)
VB.Net
C#
C++
Compiler
Compiler
Compiler
ASM Code
IL-Code
CLR
JIT Compiler
Operating system
24
Just in time Compilation (2)
Class A
(1) Method call
Method 1 (ASM)
Class B
Method 2 (IL)
Methode
1 (IL)
Method
1 (ASM)
Method 3 (IL)
Method 2 (IL)
Method 4 (IL)
JIT Compiler
(2) Replacing IL
code by native code
25
Codemanagement (1)
• Memory administration
Execution Engine (EE)
Thread 1
Thread 2
Thread 3 ...
.
.
.
List the method
conditions
Heap
List the method
conditions
26
Codemanagement (2)
– Method conditions
Method description
Safety features
arguments
Previous
condition
Local variables
Local allocations
Operands stack and output parameters
Instruction
pointer
27
Codemanagement (3)
• Garbage Collector
Laying out
objects on
the Heap
Heap and
Indicator
before
and after
a GC
NextObjPtr
Obj A
newobj A::.ctor()
NextObjPtr
newobj B::.ctor()
Obj A
Obj B
Obj A
Obj A
Obj B
Obj D
Obj C
Obj E
Obj D
GC
Obj E
Obj F
NextObjPtr
28
Assemblies and modules (1)
• Meta data in PE-Files
.Net-PE-File PE/COFF
Headers
CLR
Header
CLR Data
Meta data
IL-Code
1. a program which informs the user that this file isn't
executable under DOS
2. CLR header saves version number of the CLR for
which the program was written
29
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
30
Assemblies and modules (3)
• Assembly is a .Net-Component that Capsules,
secures and versions modules
Aim: PublicType
OtherApp.exe
.module AnotherApp
Manifest
.assembly OtherApp
Meta data
.assmbly extern mscorlib
.assmbly extern MFAApp
.class public App
CIL-Code
MFAApp.exe
.module MFAApp
Manifest
.assemblyMFAApp
.file pub.mod
.class extern public PublicType
Meta data
.assmbly extern mscorlib
.modul extern pub.mod
.class public App
CIL-Code
pub.mod
.module pub.mod
Meta data
.assmbly extern
mscorlib
.class public
PublicType
CIL-Code
31
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
32
Assemblies and modules (5)
•
Producing of version
–
–
–
1.
2.
3.
In source code with the attribute
System.Reflection.AssemblyVersionAttribute
By Assembly-Linker(al.exe) at the production of the
Assembly
Examples
Input value
result
1.2.3.4
1.2.3.4
0.0.0.0
1.2.*
1.2.745.18000
(on 15.1.2002 at 10:00:00 h)
33
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
Evidence
Policy Levels
Enterprise
Machine
User
Application Domain
Security
Manager
Assembly A
PermissionSet
...
Reflection
34
Assemblies and modules (7)
– Security stack walk
Assembly A
Assembly B
Ressource
Assembly C
Assembly D
p.Demand()
35
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)
36
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
37
ASP.NET (3)
CounterPage.cs
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;
}
38
}
ASP.NET (4)
Counter.aspx
<% @ 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>
39
ASP.NET (5)
.NET Framework
Client
(WebBrowser)
Request
Counter.aspx
Response
*.html
Server
(IIS)
ASP
.NET
Counter.aspx
Counter.dat
40
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 webservice-implementation, produces objects and/or
deletes them
41
Web-Sevices (2)
1. Registering
2. search
UDDI
WebService A
Book 3. Connection
Paradise 4. Get data
WebService B
42
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)
43
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
44
Summary (1)
•
•
•
•
•
•
„What is .NET?“
virtual machine
Common Type System (CTS)
Common Language Specification (CLS)
Common Intermediate Language (CIL)
Codemanagement
45
Summary (2)
• Assemblies and modules
• Security
• ASP.NET
– Production of dynamic web sites
• Web-Services
– heterogeneous distributed services
46
Danke für die Aufmerksamkeit!
47