Microsoft 'NET Framework - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

Microsoft 'NET Framework

Description:

Server and Client software and tools. Framework in context. Common Language Runtime (CLR) ... Other languages will run on CLR, but only within the CLR constraints ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 42
Provided by: MarkGu
Category:
Tags: net | ado | framework | microsoft

less

Transcript and Presenter's Notes

Title: Microsoft 'NET Framework


1
Microsoft .NET Framework
  • CS2340
  • Spring 2003

2
The .NET Framework
  • What is Microsoft .NET?
  • A programming model CLR Classes
  • XML Web services
  • Server and Client software and tools

3
Framework in context
4
Common Language Runtime (CLR)
  • Its a VM (Java-like) on which any (supported)
    language can run.
  • Why a VM?
  • Memory Protection
  • Cross-language
  • Support for strong-typing across languages
  • Thread support
  • Compactness
  • Flexibility (Reflection, Meta-programming)
  • JIT compilation in the VM
  • Stack-based
  • 3 generation garbage collector

5
Languages in CLR
  • Language of choice is C (C-sharp) a Java-like
    language
  • No inner classes
  • Better type checking
  • Other languages will run on CLR, but only within
    the CLR constraints
  • Visual Basic, JScript are full fledged CLR
    languages
  • For example, only C that is VM-safe will run
  • That subset looks much like C
  • Under CLR, all languages get object features
  • Inheritance used extensively
  • Every language gets constructors

6
Supported Languages
  • Languages targeted to CLR
  • APL C
    C COBOL
  • Component Pascal Curriculum Eiffel
    Fortran
  • Haskell Java Language
    Microsoft JScript Mercury
  • Mondrian Oberon Oz
    Pascal
  • Perl Python
    RPG Scheme
  • SmallTalk Standard ML
    Microsoft Visual Basic

Languages interoperate seamlessly. Can write
part of app in scheme, part in C and part in
Smalltalk!
7
Languages compile to MSIL
  • Languages compile to MSIL (Microsoft Intermediate
    Language)
  • Can you say bytecodes?
  • MSIL is shipped in portable executable (PE) units
  • Can you say .class files or applets?
  • Includes meta-data about types
  • An application is made up of assemblies

8
Reuse
  • Tries to get maximum reuse of components/assemblie
    s (like Smalltalk)

We get this in the .NET world via assemblies.
9
Assemblies
  • In general, a static assembly can consist of four
    elements
  • The assembly manifest, which contains assembly
    metadata (required).
  • Type metadata.
  • Microsoft intermediate language (MSIL) code that
    implements the types.
  • A set of resources.

10
Assemblies can be spread across .NET
11
Assemblies are the security unit
  • Each assembly has a set of corresponding grants
  • Each grant allows certain permissions
  • DnsPermission, Environment, FileDialog, FileIO,
    IsolatedStorage, Reflection, Registry, Security,
    UI, WebPermission, SocketPermission
  • The set of grants establishes a security policy
  • Grants are determined by CLR managed code
    security policy system.

12
Assemblies
  • They are also the basic unit for
  • Versioning
  • Types
  • Reference Scope Boundary
  • Deployment
  • Side-by-side execution
  • Can be shared via the Global Assembly Cache (like
    a Squeak Image).

13
Application Domains
  • Processes provide nice separation of applications
    with separate address, security and run control.
    But Causes problems with IPC.
  • Application Domains allow multiple applications
    to run in same box, share memory and security
    rights, but also have isolation and individual
    security and run control if desired. So a
    process can run multiple applications!

14
MS .Net
15
Class Library
  • Data classes support persistent data management
    and include SQL classes.
  • XML classes enable XML data manipulation and XML
    searching and translations.
  • Windows Forms support development of Windows GUI
    applications across CLR
  • Web Forms include classes that enable you to
    rapidly develop web GUI applications.

16
Forms
17
C System.Object
  • Public methods
  • Equals
  • GetHashCode
  • GetType
  • ToString
  • Overriding inherited behaviors is common

18
C Code and Manifest
using System class MainApp public static
void Main() Console.WriteLine
("Hello World using C!")
.assembly extern mscorlib .publickeytoken
(B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 1024110 .assembly Hello // ---
The following custom attribute is added
automatically do not uncomment. ------- //
.custom instance void mscorlibSystem.Diagnostics
.DebuggableAttribute.ctor(bool, // bool)
( 01 00 00 01 00 00 ) .hash algorithm
0x00008004 .ver 0000 .module Hello.exe
// MVID 58AD9DFD-63A6-462A-8AD5-42CBC95AA147
.subsystem 0x00000003 .file alignment 512
.corflags 0x00000001 // Image base
0x03330000
19
Web, Windows, Whatever
  • Part of the idea is to smooth transitions between
    Windows and Web
  • Web interfaces become easier for Windows
    developers
  • Windows apps become .NET Web-based apps

20
MS .Net
21
Data lt-gt XML, Everywhere
  • All CLR data can be serialized to XML
  • All XML can be expanded into CLR data
  • Thus, anything can be shipped around on the Web
  • Typing through XML Schema
  • Pluggable Architecture

22
XML Schema
  • ltxsdcomplexType name"Person"gt
  • ltxsdsequencegt
  • ltxsdchoicegt
  • ltxsdelement name"name"
    type"xsdstring"
  • xsinillable"true" /gt
  • ltxsdelement name"id"
    type"xsdstring" /gt
  • lt/xsdchoicegt
  • ltxsdany processContents"lax"/gt
  • lt/xsdsequencegt
  • lt/xsdcomplexTypegt
  • ltxsdcomplexType name"AgedPerson"gt
  • ltxsdcomplexContent mixed"false"gt
  • ltxsdextension base"targetPerson"gt
  • ltxsdchoicegt
  • ltxsdelement name"age"
    type"xsddouble" /gt
  • ltxsdelement name"timeOnEarth"
    type"xsddouble" /gt
  • lt/xsdchoicegt
  • lt/xsdextensiongt
  • lt/xsdcomplexContentgt

23
Example Instance
  • ltnsdon
  • xmlnsns"uuid048b2fa1-d557-473f-ba4c-
  • acee78fe3f7d"
  • gt
  • ltnamegtDon Boxlt/namegt
  • ltniceStuffForDon/gt
  • lt/nsdongt

24
Second Example Instance
  • ltnsdon
  • xmlnsns"uuid048b2fa1-d557-473f-ba4c-acee78f
    e3f7d"
  • xmlnsxsi"http//www.w3.org/2001/XMLSchema-in
    stance"
  • xsitype"nsAgedPerson"
  • gt
  • ltnamegtDon Boxlt/namegt
  • ltniceStuffForDon/gt
  • ltagegt26lt/agegt
  • lt/nsdongt

25
A Simpler Schema
  • ltelement name"Book"gt
  • ltcomplexTypegt
  • ltelement name"author" type"xsdstring"/gt
  • ltelement name"preface" type"xsdstring"/gt
  • ltelement name"intro" type"xsdstring"/gt
  • lt/complexTypegt
  • lt/eBookgt

26
Another Example Instance
  • lteBookgt
  • ltauthorgtHenry Fordlt/authorgt
  • ltprefacegtPrefatory textlt/prefacegt
  • ltintrogtThis is a book.lt/introgt
  • lt/eBookgt

27
XML Schema Defined Types
28
Class Library Type Hierarchy
29
Reading in XML Data
  • XmlReader reader
  • new XmlTextReader("http//foo.com/don.
    xsd")
  • XmlSchema schema XmlSchema.Load(reader, null)
  • schema.Compile(null) // turn xml into objects
  • reader.Close()

30
Serialized Classes
public class OrderForm public DateTime
OrderDate private int foo
ltOrderFormgt ltOrderDategt12/12/01lt/OrderDategt
lt/OrderFormgt
Note Only public instance data and properties
are serialized with XML.
31
ALL Interprocess Communication via SOAP
  • ALL Interprocess communication (across network or
    on same machine) is through SOAP
  • Simple Object Access Protocol
  • Its a way of exchanging data and even calling
    other methods/threads, all via XML and plain old
    HTTP requests

32
SOAP 1.2
  • SOAP is a lightweight protocol intended for
    exchanging structured information in a
    decentralized, distributed environment. SOAP uses
    XML technologies to define an extensible
    messaging framework, which provides a message
    construct that can be exchanged over a variety of
    underlying protocols. The framework has been
    designed to be independent of any particular
    programming model and other implementation
    specific semantics.

33
Example SOAP Request
  • ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
    org/soap/envelope/"gt
  • ltsoapBodygt
  • ltxTransferFunds xmlnsx"urnexamples-orgban
    king"gt
  • ltfromgt22-342439lt/fromgt
  • lttogt98-283843lt/togt
  • ltamountgt100.00lt/amountgt
  • lt/xTransferFundsgt
  • lt/soapBodygt
  • lt/soapEnvelopegt

34
Example SOAP Response
ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/"gt ltsoapBodygt
ltxTransferFundsResponse xmlnsx"urnexamples-org
banking"gt ltbalancesgt
ltaccountgt ltidgt22-342439lt/idgt
ltbalancegt33.45lt/balancegt
lt/accountgt ltaccountgt
ltidgt98-283843lt/idgt
ltbalancegt932.73lt/balancegt
lt/accountgt lt/balancesgt
lt/xTransferFundsResponsegt lt/soapBodygt
lt/soapEnvelopegt
35
Example SOAP Fault
ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/"gt ltsoapBodygt
ltsoapFaultgt ltfaultcodegtsoapServerlt/fau
ltcodegt ltfaultstringgtInsufficient
fundslt/faultstringgt ltdetailgt
ltxTransferError xmlnsx"urnexamples-orgbank
ing"gt ltsourceAccountgt22-34243
9lt/sourceAccountgt
lttransferAmountgt100.00lt/transferAmountgt
ltcurrentBalancegt89.23lt/currentBalancegt
lt/xTransferErrorgt
lt/detailgt lt/xTransferFundsgt
lt/soapBodygt lt/soapEnvelopegt
36
Soap Request with Security
ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/"gt ltsoapBodygt
ltxTransferFunds xmlnsx"urnexamples-orgbanking
"gt ltfromgt22-342439lt/fromgt
lttogt98-283843lt/togt ltamountgt100.00lt/amountgt
lt!-- security credentials --gt
ltcredentialsgt ltusernamegtdavelt/usernamegt
ltpasswordgtevadlt/passwordgt
lt/credentialsgt lt/xTransferFundsgt
lt/soapBodygt lt/soapEnvelopegt
37
MS .Net
38
ASP.NET
  • ASP gt Active Server Pages
  • Put most of the computation in the server
  • Very simple model to use
  • ADO.NET is the database connection part

39
Calling Web Services
  • Any class can be converted into an XML Web
    Service with just a few lines of code, and can be
    called by any SOAP client. 

40
Take-away lessons
  • VMs are important
  • Even Microsoft thinks so
  • Distributed apps are important, but to do so
    requires standard protocols
  • Ways of serializing data (XML)
  • Ways of doing RPC (SOAP)
  • Design Decisions Good and Bad

41
Limitations of the .NET Framework
  • What if youre not on the network?
  • Maybe thats not an issue?
  • Mapping between XML and any object is hard
  • Any object is controlled by compiler. XML can
    be written by anybody with a text editor.
  • Theres a whole bunch of class support for
    modified serializers and compilers
Write a Comment
User Comments (0)
About PowerShow.com