Embed
Email

msnet

Document Sample
msnet
Shared by: HC11111023946
Categories
Tags
Stats
views:
2
posted:
11/10/2011
language:
English
pages:
69
Microsoft .NET





Gaurav Gupta

Dinesh Chandnani





CSc 630 Spring 2002

Acknowledgements

• Microsoft MSDN http://www.msdn.microsoft.com/library

• Microsoft GotDotNet http://www.gotdotnet.com

• Sun Microsystems http://www.java.sun.com

• Csharp Help http://www.csharphelp.com

• Sam Gentiles Website

http://www.project-inspiration.com/sgentile/

• Brinkster Web Hosting http://www.brinkster.com

• DotNetBuzz http://www.dotnetbuzz.com

• .netWire http://www.dotnetwire.com

• The IT Portal http://www.theitportal.com/dotnet

• .NET Experts http://www.dotnetexperts.com



CSc 630: Microsoft .NET .NET-2

Outline

Microsoft Vision



• .NET Design Goals



• .NET Framework



• Visual Studio.NET



• Web Services



• .NET vs J2EE



• Conclusion





CSc 630: Microsoft .NET .NET-3

Microsoft Vision





Empower people, any time, any place,



and on any device through great software









CSc 630: Microsoft .NET .NET-4

Outline

Microsoft Vision



• .NET Design Goals



• .NET Framework



• Visual Studio.NET



• Web Services



• .NET vs J2EE



• Conclusion





CSc 630: Microsoft .NET .NET-5

.NET Design Goals



• Unifies programming models



• Dramatically simplifies development



• Provides robust execution environment



• Supports multiple programming languages



• Natively supports XML Web Services







CSc 630: Microsoft .NET .NET-6

Outline

Microsoft Vision



• .NET Design Goals



• .NET Framework



• Visual Studio.NET



• Web Services



• .NET vs J2EE



• Conclusion





CSc 630: Microsoft .NET .NET-7

The .NET Framework



VB C++ C# JScript …



Common Language Specification









Visual Studio.NET

ASP.NET: Web Services Windows

and Web Forms Forms



ADO.NET: Data and XML



Base Class Library





Common Language Runtime



CSc 630: Microsoft .NET .NET-8

Terminology "ABC"



• CLR: Common Language Runtime

 One runtime for many programming languages



• Assembly

 Container for code, metadata and resources—your new term for

what you used to call “D-L-L“



• Intermediate Language (IL)

 One intermediate, high-level assembly-style language that is

emitted by language compilers



• Metadata

 Information that describes the shape of data and the runtime

behavior of a program



CSc 630: Microsoft .NET .NET-9

Execution Model: CLR



Source VB C# C++

code

Unmanaged

Compiler Compiler Compiler

Component



Managed Assembly Assembly Assembly

code IL Code IL Code IL Code







Common Language Runtime



JIT Compiler





Native Code



Operating System Services





CSc 630: Microsoft .NET .NET-10

Common Language Runtime



• Robust and secure execution environment

 Type safe, garbage-collecting



• Common for multiple languages

 Deep-integration options



• Simplifies deployment and management

 No registry involved, zero-impact install

 Side-by-site execution of multiple versions



• Potentially Multi-Platform ?







CSc 630: Microsoft .NET .NET-11

Common Language Runtime



• Execution environment for "managed code"



• Managed?

 Code resides on disk as IL

 Must be translated into machine code

 Code references other code

 Other code residing in other assemblies must be found

 Memory must be managed

 .NET employs a garbage collector to do that job

 Execution must be as secure as possible

 Safeguard code against viruses and worms









CSc 630: Microsoft .NET .NET-12

CLR Execution Model: Conceptual



Compilation



Source Language Code (IL)

Assembly

Code Compiler Metadata









Before installation or

Native JIT the first time each

method is called

Code Compiler



Execution



CSc 630: Microsoft .NET .NET-13

Assembly



• Assemblies

 contains the code that CLR executes



 functional building blocks



 self-aware



 retrieve any dependant assemblies



 does not execute without Assembly Manifest







CSc 630: Microsoft .NET .NET-14

Assembly



• Assemblies are loadable entities containing

 Assembly metadata

 Type metadata

 MSIL code

 Resources





• Assemblies contain:

 Modules





• Consists of one or multiple physical files

 Bundled by a "packing list": The Manifest









CSc 630: Microsoft .NET .NET-15

Manifest: Standard Elements



• Manifest is a table with information records



• Manifest contains information about:

 Assembly name

 Version information

 Processor and OS

 Files that make up this assembly

 References to types and resources









CSc 630: Microsoft .NET .NET-16

Modules

• Module is a compiled unit

• Modules contain metadata and IL

 Metadata describes structure

 IL describes runtime behavior



• Modules cannot be loaded independently

 Must be contained in assembly









CSc 630: Microsoft .NET .NET-17

Intermediate Language (IL)



• .NET languages are compiled to an Intermediate

Language (IL).



• CLR accepts the IL code and recompiles it to machine

code.



• The recompilation is just-in-time (JIT) meaning it is

done as soon as a function or subroutine is called.



• The JIT code stays in memory for subsequent calls.



• In cases where there is not enough memory it is

discarded.





CSc 630: Microsoft .NET .NET-18

Outline

Microsoft Vision



• .NET Design Goals



• .NET Framework



• Visual Studio.NET



• Web Services



• .NET vs J2EE



• Conclusion





CSc 630: Microsoft .NET .NET-19

MSIL: Hello World

class HelloWorld {

public static void Main() {

System.Console.WriteLine("Hello World");

}

}

.assembly hello {}

.assembly extern mscorlib {}

.method static public void main() il managed {

.entrypoint

.maxstack 1

ldstr "Hello World from IL!"

call void [mscorlib]System.Console::WriteLine(class

System.String)

ret }





CSc 630: Microsoft .NET .NET-20

Metadata



• A type must be self descriptive: It must describe

properties and methods that it exposes.





• Examples:



 The type Integer describes what values it takes and what

operations it accepts.



 The type Check describes what values (e.g., AccountNo and

Amount) it takes and what operations (e.g., Cash, Deposit) it

accepts.







CSc 630: Microsoft .NET .NET-21

.NET JVM: CLR



• JIT (Just-In-Time)

 compiles methods

 caches the native code





• Verify MSIL to be type safe





• Managed code can contain platform specific

calls and dependencies.







CSc 630: Microsoft .NET .NET-22

Common Type System









CSc 630: Microsoft .NET .NET-23

.NET Class Library



• In traditional environments different categories of services

are provided to the programmer via libraries such as: C

run time library, Win32 APIs, I/O and database access

libraries, etc.



• These libraries are language dependent, operating

system dependent, and often contain simple subroutine

calls as opposed to self describing types.



• In .NET all services fall into a single, hierarchy organized,

language independent class library









CSc 630: Microsoft .NET .NET-24

The Collector In Action









Generation 1 Generation 0



• New heap begins with new generation

• Accessible references keep objects alive

• Preserves / Compacts referenced objects

• Objects left merge with older generation

• New allocations rebuild new generation

CSc 630: Microsoft .NET

CSc 630: Microsoft .NET .NET-25

.NET-25

Garbage Collection



• The CLR includes garbage collection.



• Managed heap always points to the next available spot, so

allocation speed is closer to stack allocation.



• Memory is allocated successively, resulting in fewer page

faults and improved cache use.



• System.GC gives access to the GC:



GC::Collect(int generation) etc.





CSc 630: Microsoft .NET .NET-26

Outline

Microsoft Vision



• .NET Design Goals



• .NET Framework



• Visual Studio.NET



• Web Services



• .NET vs J2EE



• Conclusion





CSc 630: Microsoft .NET .NET-27

Visual Studio .NET





• Supports multi-language



• Designs applications more quickly



• Builds solutions with rule-enforcement templates



• Tests applications for stability









CSc 630: Microsoft .NET .NET-28

VS.NET Core Languages



• Visual Basic

 Substantial language innovation

 First class .NET language

 Leverage existing skills





• C#

 More productive C/C++ language for .NET

 Full RAD support





• Visual C++

 Still most powerful and flexible language

 Enables incremental migration to .NET





CSc 630: Microsoft .NET .NET-29

Other Languages. . .





• Perl • Pascal

• Python • C++

• COBOL • Visual Basic

• Eiffel • C#

• Haskell • SmallTalk

• ML • Oberon

• JScript • Scheme

• Ada • Mercury

• APL • Objective Caml

• C • Oz









CSc 630: Microsoft .NET .NET-30

C#



• Modern object oriented, type-safe, garbage collected



• Familiar to C/C++ programmers.



• Integrated COM, Platform API, and XML support



• No class libraries, uses only common .NET libraries



• Implementation of a new language with full support for the

.NET framework.





CSc 630: Microsoft .NET .NET-31

C#

Java

C# Class structure

Single inheritance

Interfaces

Garbage Collection

Code safety

Convenience & Reflection

JavaDoc

Additional

Features

Properties C++

Indexes Feature richness,

Attributes Direct access to memory

Delegates Legacy keywords



CSc 630: Microsoft .NET .NET-32

Interface and Class in C#





Public interface Icalc {

int add(int x, int y);

int subtract(int x, int y);

}



Public class Calculator : Icalc {

int add(int x, int y) {

return x + y;

}



int subtract(int x, int y) {

return x-y;

}

}









CSc 630: Microsoft .NET .NET-33

Interface and Class in VB.NET



Public Interface Icalc

Function Add(X As Integer, Y as Integer)

Function Subtract(X As Integer, Y as Integer)

End Interface



Public Class Calculator

Implements ICalc

Function Add(X as Integer, Y as Integer)

Implements Icalc.Add

Add = x + y

End Function



Function Subtract(X as Integer, Y as Integer)

Implements Icalc.Subtract

Subtract = x – y

End Function

End Class







CSc 630: Microsoft .NET .NET-34

C++



• Managed C++ can be used to write .NET Framework

applications



• It relies on extensions to the standard language



• C++ will be important for non-Framework-based

applications



• The core semantics of C++ does not match with CLR









CSc 630: Microsoft .NET .NET-35

Cross-Language Interoperability

‘This is a VB.NET code



Namespace MyCSClass



Public Class CSClass



Public Sub CSClass()

'code

End Sub



‘returns the length of the passed string

Public MyMethod(str As String) As Integer

MyMethod = str.Length;

End Sub



‘returns n squared

Virtual Public MyVirtualMethod(n As Integer) As Integer

MyVirtualMethod = n*n;

End Sub



End Class



CSc 630: Microsoft .NET .NET-36

Cross-Language Interoperability



Can use components written in different languages



How ?



#using "MyCSClass.dll"



using namespace MyCSClass;



CSClass *cs = new CSClass();



// will return 11

int result;

result = cs->MyMethod("Hello World");



// will return 2 squared

result = cs->MyVirtualMethod(2);









CSc 630: Microsoft .NET .NET-37

Cross-Language Inheritance

• Derive a new class in language C from MyClass

class NewClass : public MyCSClass::CSClass





• Override virtual method. . .

virtual int MyVirtualMethod( int param )



• And access your new class normally. . .

NewClass *newCls = new NewClass();

result = newCls->MyVirtualMethod(param);



• All this without the source code to the previous

component or knowledge of it s language.

class CPPClass : public MyCSClass::CSClass {

public: // returns the cube of the given number

virtual int MyVirtualMethod(int n) {

return n*n*n;

}

};

CSc 630: Microsoft .NET .NET-38

Cross-Language Features



Support across components and languages:



• Inheritance



• Exception handling



• Debugging



• Good for extending 3rd party components in the

language of your choice.









CSc 630: Microsoft .NET .NET-39

Visual Basic Form as a Class

• All .NET languages use the same tools (WinForms) to

create the user interface of an application as a form

• A form a class containing other classes (called controls)

such as TextBox, ListBox or Button

• The act of drawing a form (such as Form1) generates the

VB.NET code that defines the corresponding class named

Form1

• As a class, Form1 has methods, properties, and events.

 Form1.Show is a method that displays the Form1 on the screen.

 Form1.EmpName.Text references the contents of the TextBox

EmpName in Form1.

 EmpName_Change is the name of the event handler that is invoked

when the user changes contents of EmpName TextBox.





CSc 630: Microsoft .NET .NET-40

Server-Side Controls





• ASP and JSP provide a language to generate HTML

markups. In ASP.NET the complexity of this language

is significantly reduced by using server-side controls.



• For each HTML control there exists a server-side

control in ASP.NET.









CSc 630: Microsoft .NET .NET-41

VB.NET ASP.NET APPLICATION



Public Sub doClick(sender as object, e as EventArgs)

TheLabel.Text = "Hello, world! (from ASP.NET in VB NET,code inline)"

End Sub







In-line ASPX

file in VB .NET





VB .NET ASP.NET application

with inline code















CSc 630: Microsoft .NET .NET-42

C# ASP.NET APPLICATION



void doClick(object sender, EventArgs e) {

TheLabel.Text = "Hello, world! (from ASP.NET in C#, code inline)";

}







In-line ASPX

file in C#



C# ASP.NET application

with inline code

















CSc 630: Microsoft .NET .NET-43

Why another Data Access API?





• Most new applications are



 Loosely coupled - even disconnected



 More and more use XML to encode data







• This is very different from the classical connected,

tightly coupled client/server model









CSc 630: Microsoft .NET .NET-44

ADO.NET & XML Integration



XSLT, Xpath Visual Studio.NET

Validation Designers & Controls







Managed

XMLDataDocument DataSet

Mapping Provider





XMLReader

XMLTextReader XMLNodeReader







XML

XML Stream Document SQL Server

CSc 630: Microsoft .NET .NET-45

.NET and DOM



Fred

Bill











XmlDocument doc = new XmlDocument();

doc.Load( "test.xml" );

XmlNode root = doc.DocumentElement;

foreach( XmlNode personElement in root.ChildNodes )

Console.WriteLine( personElement.FirstChild.Value.ToString()

);





Fred

Bill







CSc 630: Microsoft .NET .NET-46

.NET and XPath



// This is C# code



XPathDocument xpdoc = new XPathDocument("test.xml");

XPathNavigator nav = xpdoc.CreateNavigator();

XPathExpression expr =

nav.Compile("descendant::PEOPLE/PERSON");



XPathNodeIterator iterator = nav.Select(expr);

while (iterator.MoveNext())

Console.WriteLine(iterator.Current);









CSc 630: Microsoft .NET .NET-47

Outline

Microsoft Vision



• .NET Design Goals



• .NET Framework



• Visual Studio.NET



• Web Services



• .NET vs J2EE



• Conclusion





CSc 630: Microsoft .NET .NET-48

What is .NET Web Services ?



Users store, access and share based information

anytime, any place, from any device

XML

Web Service

Message Internet









Developers create

and deliver Operators run efficient,

compelling solutions secure, and reliable data

to huge customer centers for their user

base base





CSc 630: Microsoft .NET .NET-49

.NET Web Services



/* Hello.asmx */

using System.Web.Services;

public class Hello: WebService {

[ WebMethod ]

public string IssueGreeting() {

return "Hello, World!";

}

}









CSc 630: Microsoft .NET .NET-50

.NET Web Services



/* Hello.asmx */

using System.Web.Services;

public class Hello: WebService {

[ WebMethod ]

public string IssueGreeting() {

return "Hello, World!";

}

}









CSc 630: Microsoft .NET .NET-51

.NET Web Services



/* Hello.asmx */

using System.Web.Services;

public class Hello: WebService {

[ WebMethod ]

public string IssueGreeting() {

return "Hello, World!";

}

}









CSc 630: Microsoft .NET .NET-52

User-Centric Web Services





.NET Profile .NET Devices

.NET

.NET Categories Application Settings









.NET Calendar

.NET

Favorite Web Sites .NET Presence





.NET Alerts



.NET Inbox .NET Documents





.NET Wallet



.NET Contacts .NET Location







CSc 630: Microsoft .NET .NET Lists .NET Services .NET-53

Before .NET My Services

Web App

Local Store









Local Store







• Multiple disconnected local stores

Sync

Replication

• Sharing information between

applications and devices is difficult

• Sharing with others impossible

• You have to remember to

Local Store synchronize

manual data entry into smaller

devices







Local Store







CSc 630: Microsoft .NET .NET-54

After .NET My Services

Web App









Shared Store







• Single shared store

• Sharing is easy and natural

• Sharing with others is second nature

• Information is always correct,

accurate, live









CSc 630: Microsoft .NET .NET-55

Not Just Users









Groups

Individuals

Organizations







.NET Calendar .NET Contacts .NET Contacts

.NET Contacts







.NET Alerts .NET Inbox .NET Calendar .NET Calendar





CSc 630: Microsoft .NET .NET-56

Using the MyServices Together

Travel Agent Example



A simple way for customer Passport Authentication,

to be identified at the site myProfile, other my* services

Easy for customer to pay myWallet

Match customer’s vacation myCalendar of customer

dates with available hotels myCalendar of hotel vacancies

Tickets purchased become

available at a lower price, myNotifications (any device)

or flights delayed/canceled

Coordinate with customer’s myContacts, myInbox,

friends or family myCalendar

Advise customers about myLocation

local events and offers

CSc 630: Microsoft .NET .NET-57

Outline

Microsoft Vision



• .NET Design Goals



• .NET Framework



• Visual Studio.NET



• Web Services



• .NET vs J2EE



• Conclusion





CSc 630: Microsoft .NET .NET-58

.NET Architecture









CSc 630: Microsoft .NET .NET-59

J2EE Architecture









CSc 630: Microsoft .NET .NET-60

CLR versus JVM



VB Managed

J# C# .NET C++ Java

MSIL Byte Codes



CLR JVM

CTS GC Security GC Security

Runtime Services Runtime Services



Windows OS Mac Win Unix Linux







Both are middle layers between an intermediate

language and the underlying OS



CSc 630: Microsoft .NET .NET-61

CLR versus JVM



• CLR  language independence



 Multiple languages for development



 Underlying OS: Windows (?)





• JVM  platform independence



 Single language: Java (?)



 A separate JVM for each OS & device









CSc 630: Microsoft .NET .NET-62

JUMP to .NET



• JUMP: Java User Migration Path





• Consists of 2 important tools:



 A Java-to-C# tool to convert Java source code into C# codes.

Migration of syntax & library calls. Unconvertable Java codes

will be tagged for manual conversion.



 Visual J# .NET









CSc 630: Microsoft .NET .NET-63

J#.NET



• J# is not Java (.java)

• It is Java Language Syntax (.jsl)

• J# compiler: J# -> MSIL

• jbimp.exe: Java bytecode -> MSIL

• Does not support the generation of .class bytecode

files (Sun technologies)

• Implementation of an old language so that legacy

applications can run with access to the .NET

framework.





CSc 630: Microsoft .NET .NET-64

J# .NET



• Can make use of .NET modules written in other

languages in your J# module

• Can integrate new .NET functionality such as ADO

.NET, web services, Windows forms, ASP .NET into

your J# module

• Can consume .NET framework libraries in J#

• Applications written using J# can only run on .NET

framework, not on a JVM

• J# does not compile .java files to .class files

• J# includes Jbimp tool which can convert .class files to

IL assemblies





CSc 630: Microsoft .NET .NET-65

.NET vs J2EE









.NET Pet Shop, Sun's best-practice application, has same

functionality as the J2EE version, but

• uses one-third the code of the J2EE version.

• performance exceeds that of the J2EE version by 28 times



CSc 630: Microsoft .NET .NET-66

Outline

Microsoft Vision



• .NET Design Goals



• .NET Framework



• Visual Studio.NET



• Web Services



• .NET vs J2EE



• Conclusion





CSc 630: Microsoft .NET .NET-67

Conclusion



• .NET makes it easier to design a good solution

 Object Oriented

 Native Support for Many Design Goals

 Native Support for Web Services





• Visual Studio makes it easier to implement a good solution

 Multi-Project Solutions

 Multi-Language Solutions

 Excellent Debugging

 Productivity Enhancements









CSc 630: Microsoft .NET .NET-68

Microsoft .NET









Questions ?









CSc 630: Microsoft .NET .NET-69


Related docs
Other docs by HC11111023946
vb
Views: 25  |  Downloads: 0
student information sheet
Views: 0  |  Downloads: 0
046 2106
Views: 2  |  Downloads: 0
mvvm
Views: 0  |  Downloads: 0
Song 20Index 20Sept10
Views: 4  |  Downloads: 0
Life_and_Teaching Vol_3
Views: 0  |  Downloads: 0
truman
Views: 2  |  Downloads: 0
resume
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!