+ All Categories
Home > Education > .Net framework

.Net framework

Date post: 07-Aug-2015
Category:
Upload: teach4uin
View: 46 times
Download: 4 times
Share this document with a friend
27
Introduction to .Net framework BY-Teach4u.in
Transcript
Page 1: .Net framework

Introduction to .Net framework

BY-Teach4u.in

Page 2: .Net framework

The .NET Framework

What is Microsoft .NET?A programming model: CLR + ClassesXML Web servicesServer and Client software and tools

Page 3: .Net framework

Common Language Runtime (CLR)It’s a VM (Java-like) on which any

(supported) language can run.Why a VM?

Memory ProtectionCross-languageSupport for strong-typing across languages

(the data are typed)Thread support

JIT compilation in the VM

Page 4: .Net framework

Languages in CLRLanguage of choice is C# (“C-sharp”) a Java-like

languageNo inner classesBetter type checking

Other languages will run on CLR, but only within the CLR constraintsVisual Basic, JScript are full fledged CLR languagesFor example, only C++ that is VM-safe will runThat subset looks much like C#

Under CLR, all languages get object features Inheritance used extensivelyEvery language gets constructors

Page 5: .Net framework

Languages compile to MSILLanguages compile to MSIL (Microsoft

Intermediate Language)Can you say “bytecodes”?

MSIL is shipped in portable executable (PE) unitsCan you say .class files or applets?

An application is made up of assemblies

Page 6: .Net framework

Assemblies In general, a static

assembly can consist of four elements:

The assembly manifest, which contains assembly metadata.

Type metadata. Microsoft intermediate

language (MSIL) code that implements the types.

A set of resources.

Page 7: .Net framework

Assemblies can be spread across .NET

Page 8: .Net framework

Assemblies are the security unitEach 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

Page 9: .Net framework

Class LibraryData 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 CLRWeb Forms include classes that enable you to

rapidly develop web GUI applications.

Page 10: .Net framework

System.ObjectPublic methods:

EqualsGetHashCodeGetTypeToString

Overriding inherited behaviors is common

Page 11: .Net framework

Web, Windows, WhateverPart of the idea is to smooth transitions

between Windows and WebWeb interfaces become easier for Windows

developersWindows apps become .NET Web-based apps

Page 12: .Net framework

Data <-> XML, EverywhereAll CLR data can be

serialized to XMLAll XML can be expanded

into CLR dataThus, anything can be

shipped around on the Web

Typing through XML Schema

Page 13: .Net framework

XML Schema<xsd:complexType name="Person"> <xsd:sequence> <xsd:choice> <xsd:element name="name" type="xsd:string" xsi:nillable="true" /> <xsd:element name="id" type="xsd:string" /> </xsd:choice> <xsd:any processContents="lax"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="AgedPerson"> <xsd:complexContent mixed="false"> <xsd:extension base="target:Person"> <xsd:choice> <xsd:element name="age" type="xsd:double" /> <xsd:element name="timeOnEarth" type="xsd:double" /> </xsd:choice> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="don" type="target:Person" />

Page 14: .Net framework

Example Instance<ns:don xmlns:ns="uuid:048b2fa1-d557-473f-ba4c- acee78fe3f7d" > <name>Don Box</name> <niceStuffForDon/> </ns:don>

Page 15: .Net framework

Second Example Instance<ns:don xmlns:ns="uuid:048b2fa1-d557-473f-ba4c-acee78fe3f7d" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns:AgedPerson" > <name>Don Box</name> <niceStuffForDon/> <age>26</age></ns:don>

Page 16: .Net framework

A Simpler Schema

<element name="Book"><complexType> <element name="author"

type="xsd:string"/> <element name="preface"

type="xsd:string"/> <element name="intro"

type="xsd:string"/></complexType></e:Book>

Page 17: .Net framework

Another Example Instance

<e:Book> <author>Henry Ford</author> <preface>Prefatory text</preface> <intro>This is a book.</intro></e:Book>

Page 18: .Net framework

XML Schema Defined Types

Page 19: .Net framework

Class Library Data Hierarchy

Page 20: .Net framework

Reading in XML DataXmlReader reader = new XmlTextReader("http://foo.com/don.xsd");

XmlSchema schema = XmlSchema.Load(reader, null);schema.Compile(null); // turn xml into objectsreader.Close();

Page 21: .Net framework

ALL Interprocess Communication via SOAPALL Interprocess communication (across

network or on same machine) is through SOAPSimple Object Access ProtocolIt’s a way of exchanging data and even calling

other methods/threads, all via XML and plain old HTTP requests

Page 22: .Net framework

Example SOAP RequestPOST /StockQuote HTTP/1.1Host: www.stockquoteserver.comContent-Type: text/xml; charset="utf-8"Content-Length: nnnnSOAPAction: "Some-URI"<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m="Some-URI"> <symbol>DIS</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 23: .Net framework

Example SOAP ResponseHTTP/1.1 200 OKContent-Type: text/xml; charset="utf-8"Content-Length: nnnn

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

<SOAP-ENV:Body> <m:GetLastTradePriceResponse xmlns:m="Some-URI"> <Price>34.5</Price> </m:GetLastTradePriceResponse> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 24: .Net framework

ASP.NETASP =>

Active Server PagesPut most of the

computation in the server

Very simple model to use

ADO.NET is the database connection part

Page 25: .Net framework

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. 

Page 26: .Net framework

Take-away lessonsVM’s are important

Even Microsoft thinks soDistributed apps are important, but to do so

requires standard protocolsWays of serializing dataWays of doing RPC

Page 27: .Net framework

Limitations of the .NET FrameworkWhat if you’re not on the network?

Maybe that’s not an issue?Mapping between XML and any object is

hardAny object is controlled by compiler.

XML can be written by anybody with a text editor.

There’s a whole bunch of class support for modified serializers and compilers


Recommended