introduction to dot net siddhesh

Post on 12-Jun-2015

2.168 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

High level introduction to .NET

TRANSCRIPT

Persistent Systems Private Limitedhttp://www.persistent.co.in

Introduction to .NET

Siddhesh Bhobe

Persistent Systems Private Limitedhttp://www.persistent.co.in

Agenda

• What is .NET?• .NET framework and building blocks• ADO.NET• Web Services in .NET• DNA to .NET Migration

Persistent Systems Private Limitedhttp://www.persistent.co.in

What is Microsoft .NET?

From the Microsoft site:

“Microsoft .NET is Microsoft’s XML Web services platform. .NET contains all that’s needed to build and run software based on XML, the lingua franca of Internet data exchange.”

.NET includes:

1. The .NET Platform, which is a set of programming tools and infrastructure to enable the creation, deployment, management, and aggregation of XML Web services.

2. .NET experiences (applications!), which are the means for end users to interact with .NET.

Persistent Systems Private Limitedhttp://www.persistent.co.in

The .NET Platform

• NET Framework and Visual Studio .NET • Server infrastructure

– Application Center 2000; – BizTalk™ Server 2000;– Host Integration Server 2000;– Mobile Information 2001 Server; and– SQL Server™ 2000

• Building block services– They include Passport (for user identification) and services for

message delivery, file storage, user-preference management, calendar management, and other functions.

• Smart Devices– Enables PCs, laptops, workstations, smart phones, handheld

computers, Tablet PCs, game consoles, and other smart devices to operate in the .NET universe.

Persistent Systems Private Limitedhttp://www.persistent.co.in

The .NET Framework

Persistent Systems Private Limitedhttp://www.persistent.co.in

1st generation web applications

OS OS ServicesServices

Microsoft provided IIS, IE and COM

Applications largely operating in a client / server model were augmented with web browser and servers.

BrowsersBrowsersBrowsersBrowsers

Web app developers took advantage of these local services and used HTML to “project” the UI to many types of clients.

ServersServersData, HostsData, HostsServersServers

Data, HostsData, HostsUI LogicUI Logic

Biz LogicBiz Logic

Persistent Systems Private Limitedhttp://www.persistent.co.in

2nd generation of web applications

Combination of “stateless” Web protocols with DNS and IP routing have enabled mass-scale “Geo-Scalability”

““Stateful”Stateful”

““Stateless” &Stateless” &““Geo-Scalable”Geo-Scalable”

OS OS ServicesServices

Biz LogicBiz LogicTierTier

Biz LogicBiz LogicTierTierRich Client Rich Client

UI LogicUI LogicRich Client Rich Client

UI LogicUI Logic ServersServersData, HostsData, HostsServersServers

Data, HostsData, Hosts

Richer Richer BrowsersBrowsersRicher Richer

BrowsersBrowsers

Separation of data and business logic provide greater scalability and performance while accessing enterprise data.

*COM+ Services improve reliability, scalability and manageability.*DHTML for better interactivity.

Persistent Systems Private Limitedhttp://www.persistent.co.in

Next Generation Applications

Richer, MoreRicher, MoreProductive UserProductive User

ExperienceExperience

Applications Become Applications Become Programmable Web ServicesProgrammable Web Services

StandardStandardBrowsersBrowsers

StandardStandardBrowsersBrowsers

SmarterSmarterClientsClients

SmarterSmarterClientsClients

SmarterSmarterDevicesDevices

SmarterSmarterDevicesDevices Open Internet Open Internet

Communications Protocols Communications Protocols (HTTP, SMTP, XML, SOAP) (HTTP, SMTP, XML, SOAP) Applications LeverageApplications Leverage

Globally-AvailableGlobally-AvailableWeb ServicesWeb Services

OS OS ServicesServices

BizBizTier LogicTier Logic

BizBizTier LogicTier LogicBiz Logic Biz Logic & & Web ServiceWeb Service

OSOSServicesServices

OSOSServicesServices

Public WebPublic WebServicesServices

Building BlockBuilding BlockServicesServices

InternalInternalServicesServices

XMLXML

XMLXML

XMLXML

ServersServersData, HostsData, Hosts

ServersServersData, HostsData, Hosts

XMLXML

OtherOther ServicesServices XMLXML

XMLXML

XMLXML

HTMLHTML

Persistent Systems Private Limitedhttp://www.persistent.co.in

Development/Deployment headaches

• Non-consistent programming model• Knowledge of plumbing code• DLL management issues –’DLL HELL’• Resource management• Non-consistent error handling• Deployment issues• Security

Persistent Systems Private Limitedhttp://www.persistent.co.in

Couldn’t we have this!

No “plumbing” is needed and objects can directly interactComponents are built on a “common” substrate.

Persistent Systems Private Limitedhttp://www.persistent.co.in

Couldn’t we have this!

Enables shared services:GC, exception handler, security, threading, debugging…

Persistent Systems Private Limitedhttp://www.persistent.co.in

Couldn’t we have this!

Common API:IO, Collections, XML, UI…

…across all languages

Persistent Systems Private Limitedhttp://www.persistent.co.in

How Much Simpler?

HWND hwndMain = CreateWindowEx( 0, "MainWClass", "Main Window", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, (HWND)NULL, (HMENU)NULL, hInstance, NULL); ShowWindow(hwndMain, SW_SHOWDEFAULT); UpdateWindow(hwndMain);

Form form = new Form();form.Text = "Main Window";form.Show();

Windows API

.NET Framework

Persistent Systems Private Limitedhttp://www.persistent.co.in

Architecture

Windows COM+ Services

Common Language Runtime

Base Class Library

ADO.NET and XML

ASP.NET Windows Forms

Common Language Specification

VB C++ C# JScript …

Visu

al Stu

dio

.NE

T

Persistent Systems Private Limitedhttp://www.persistent.co.in

Common Language Runtime

VBVBSource Source codecode

CompilerCompiler

C++C++C#C#

CompilerCompilerCompilerCompiler

AssemblyAssemblyIL CodeIL Code

AssemblyAssemblyIL CodeIL Code

AssemblyAssemblyIL CodeIL Code

Operating System ServicesOperating System Services

Common Language RuntimeCommon Language Runtime

JIT CompilerJIT Compiler

Native CodeNative Code

ManagedManagedcodecode

UnmanagedUnmanagedComponentComponent

Persistent Systems Private Limitedhttp://www.persistent.co.in

Compilation

Source CodeSource Code

C++, C#, VB or C++, C#, VB or any .NET any .NET languagelanguage

CompilerCompiler

AssemblyAssembly

DLL or EXEDLL or EXE

MetadataMetadataMetadataMetadata

IL IL Managed Managed

codecode

IL IL Managed Managed

codecode

ResourcesResourcesResourcesResources

myprogram.DLLmyprogram.DLL

Assembly is basic deployable unit in .NET

VS.NET

Csc.exe, vbc.exe, etc.

Persistent Systems Private Limitedhttp://www.persistent.co.in

AssembliesThe Building Block

• Deployment unit for types and resources: a “logical dll”• Self describing through a manifest• Fundamental unit of versioning, reuse, deployment and

permission grants and requests

Persistent Systems Private Limitedhttp://www.persistent.co.in

ADO.NET

Persistent Systems Private Limitedhttp://www.persistent.co.in

ADO.NET Architecture

OdbcConnection

OdbcCommand

OdbcDataAdapter

Odb cDataReader

ODBC .NET Data Provider

COM Inter op

ODBC

Persistent Systems Private Limitedhttp://www.persistent.co.in

ADO.NET

Persistent Systems Private Limitedhttp://www.persistent.co.in

Making Database Connection

• Using SQL Server .NET data provider. SqlConnection connSql=new SqlConnection

("Address=dotsrv;uid=sa;pwd=sql;connect Timeout=5;");

• Using OLEDB.NET Provider to connect to Oracle OleDbConnection connOle=new OleDbConnection

("Provider=OraOLEDB.Oracle.1;Data Source=_CRUISEDB; user

id=xat;password=xat;");

• Using ODBC.NET Provider to connect to OracleOdbcConnection connODBC=new OdbcConnection

("DSN=connectOra;Server=_CRUISEDB;uid=xat;pwd=xat;");

Persistent Systems Private Limitedhttp://www.persistent.co.inManaged Provider

DataReader

CommandConnection

Sync

ADO and XML in the .NET Framework

Controls,Designers,

Code-gen, etc

DataSet

XmlReader

XSL/T, X-Path, etc

XmlData-Document

DataAdapter

Persistent Systems Private Limitedhttp://www.persistent.co.in

DataSet• Relational View of Data

– Tables, Columns, Rows, Constraints

– Navigate between tables using Relations• DataRow[] orders = customer.GetChildren("custOrd");

• Source-agnostic– XML, Relational, Application data

• Remotable– No knowledge of source of data– Never holds connection state– DataSet as argument to WebMethods

• Serializes as XML Schema/Data

DataSetDataSetTablesTables

TableTable

ColumnsColumnsColumnColumn

ConstrainConstraintsts ConstraintConstraintRowsRows

RowRowRelationsRelations

RelationRelation

Persistent Systems Private Limitedhttp://www.persistent.co.in

Example: Reading/Writing XML

// Load DataSet with XMLDataSet ds = new DataSet();ds.ReadXml("inventory.xml");

// Add a record to the Inventory tableDataTable inventory = ds.Tables["Inventory"];DataRow row = inventory.NewRow();row["TitleID"]=1;row["Quantity"]=25;inventory.Rows.Add(row);

// Write out XMLds.WriteXml("updatedinventory.xml");

Persistent Systems Private Limitedhttp://www.persistent.co.in

Example: Associating an XmlDataDocument with a DataSet

private static XmlDataDocument xmlData;

public static DataSet LoadDataSet(String schema) {DataSet ds = new DataSet();ds.ReadXmlSchema(schema);xmlData = new XmlDataDocument(ds);xmlData.Load("po.xml");return ds;

}public static void SaveChanges() {

xmlData.Save("po.xml");}

Persistent Systems Private Limitedhttp://www.persistent.co.in

Example: X/Path over Relational

public static void doXml(DataSet po) {// Associate an XmlDataDocument with the DataSetXmlDataDocument xmlData = new XmlDataDocument(po);

// Do an X/Path Query XmlNodeList nodes = xmlData.SelectNodes("//Item[@qty>100]");

// Write out resultsConsole.WriteLine("Matches="+nodes.Count);foreach(XmlNode node in nodes) { DataRow row =

xmlData.GetRowFromElement((XmlElement)node); // Mark Customer for Deletion row.Delete();}

}

Persistent Systems Private Limitedhttp://www.persistent.co.in

Example: XSL/T over Relational

public static void doTransform(DataSet po) {XmlDataDocument xmlData = new XmlDataDocument(po);

// Do a TransformXslTransform xsltransform = new XslTransform();xsltransform.Load("po.xsl");XmlReader xReader = xsltransform.Transform(xmlData, null);

}

Persistent Systems Private Limitedhttp://www.persistent.co.in

Summary

• ADO.NET provides a model for bridging the gap between XML and Relational data– DataSet provides Relational View

• Persists/loads data as XML

• Persists/loads schema as XSD

• Serializes as XML with in-line schema

– XmlDataDocument provides an XML view• Exposes relational data to XML tools

• Exposes a relational subset of XML data

• Preserves Fidelity of XML

Persistent Systems Private Limitedhttp://www.persistent.co.in

Web Services in .NET

Persistent Systems Private Limitedhttp://www.persistent.co.in

Web Services are “Key” in .NET

Persistent Systems Private Limitedhttp://www.persistent.co.in

Web Services Infrastructure in .NET• IIS and COM+ provides the hosting environment• APIs

– COM for implementing the business façade, business logic, and data access layers

– ADO, OLE DB, and ODBC for implementing data access to a variety of data stores

– MSXML to help construct and consume XML messages in the Web Service listener

– Active Server Pages (ASP) or ISAPI for implementing the Web Service listener

• NLBS and Clustering for scalability• IPSec, HTTP Basic authentication, Digest

authentication, Kerberos 5 authentication, NTLM authentication, or your own custom scheme.

Persistent Systems Private Limitedhttp://www.persistent.co.in

.NET Web Services Infrastructure

• Smart Clients and Devices to consume Web Services• Suite of .NET Servers, including Win 2K family and .NET

Enterprise Servers• Development Tools

– VS.NET• Single unified IDE for all languages

• Enable applications as Web Services

• Aggregate Web Services

– .NET Framework• Build, deploy and run Web Services

Persistent Systems Private Limitedhttp://www.persistent.co.in

Service Description

• Uses WSDL to describe itself• Uses namespaces to uniquely identify service endpoints• Server-side component that map Web Services to COM components

using WSDL and Web Services Meta Language (WSML) description

Persistent Systems Private Limitedhttp://www.persistent.co.in

Service Implementation

• Several languages running on Common Language Infrastructure: VB.NET, C#, JScript

• SOAP Toolkit for constructing, transmitting, reading and processing SOAP messages

Persistent Systems Private Limitedhttp://www.persistent.co.in

Service Publishing, Discovery and Binding• Used to have DISCO for discovering Web Services• Now supports UDDI• Provides .NET UDDI server• Office XP offer support for service discovery through UDDI

Persistent Systems Private Limitedhttp://www.persistent.co.in

Service Invocation and Execution

• Use of built-in .NET SOAP message classes• Construct Web Service listeners using MSXML, ASP, ISAPI etc• Use SOAP toolkit to build a Web Service listener• Client-side components for invoking Web Services

Persistent Systems Private Limitedhttp://www.persistent.co.in

Creating and Consuming Web Services in VS.NET

Persistent Systems Private Limitedhttp://www.persistent.co.in

Create New ASP.NET Web Service Project

Persistent Systems Private Limitedhttp://www.persistent.co.in

Project and Sample Files created

Persistent Systems Private Limitedhttp://www.persistent.co.in

Add New Web Service to the Project

Persistent Systems Private Limitedhttp://www.persistent.co.in

default.asmx

<%@ WebService Language="vb" Codebehind="default.asmx.vb" Class="DegreesWebService._default" %>

Persistent Systems Private Limitedhttp://www.persistent.co.in

default.asmx.vb

Persistent Systems Private Limitedhttp://www.persistent.co.in

What makes this a web service?

1. "Imports System.Web.Services" brings in the functionality needed under this class.

2. "<WebService(Namespace := "http://tempuri.org/")> _" makes this class callable from the web.

3. "Inherits System.Web.Services.WebService", makes this class inherit all the methods and properties of this class.

4. "<WebMethod()>" in front of a method makes this callable from the web.

Persistent Systems Private Limitedhttp://www.persistent.co.in

Our Web Service

Persistent Systems Private Limitedhttp://www.persistent.co.in

Building and testing the web service• Make sure that our starting page for the project is

the default.asmx page• Then go to Debug > Start, or press F5. VS builds

the project and pops up a web browser window with this file.

• This is simply a medium that Microsoft has provided so that we can test our Web Service.

Persistent Systems Private Limitedhttp://www.persistent.co.in

Testing a web service

Persistent Systems Private Limitedhttp://www.persistent.co.in

Enter Values…

Persistent Systems Private Limitedhttp://www.persistent.co.in

Invoke…

Persistent Systems Private Limitedhttp://www.persistent.co.in

Add Web Reference

Persistent Systems Private Limitedhttp://www.persistent.co.in

Web Reference added

Persistent Systems Private Limitedhttp://www.persistent.co.in

Modified default.aspx

Persistent Systems Private Limitedhttp://www.persistent.co.in

Code behind

Persistent Systems Private Limitedhttp://www.persistent.co.in

DNA to .NET Migration

Persistent Systems Private Limitedhttp://www.persistent.co.in

Windows NT 4/Windows 2000

Windows DNA architecture

COM

COM

COMIIS

ASPSQLSQL

Persistent Systems Private Limitedhttp://www.persistent.co.in

.NET Framework

• Common Language Runtime• Managed data and code• Unified framework library• Multiple language support

#include <stdio.h>int main() { int a[100]; for (int x=0; x<100; x++) a[x]=x*x; for (int y=0; y<100; y++) a[y] = y*y; return 0;}

#include <stdio.h>int main() { int a[100]; for (int x=0; x<100; x++) a[x]=x*x; for (int y=0; y<100; y++) a[y] = y*y; return 0;}

#include <stdio.h>int main() { int a[100]; for (int x=0; x<100; x++) a[x]=x*x; for (int y=0; y<100; y++) a[y] = y*y; return 0;}

#include <stdio.h>int main() { int a[100]; for (int x=0; x<100; x++) a[x]=x*x; for (int y=0; y<100; y++) a[y] = y*y; return 0;}

#include <stdio.h>int main() { int a[100]; for (int x=0; x<100; x++) a[x]=x*x; for (int y=0; y<100; y++) a[y] = y*y; return 0;}

#include <stdio.h>int main() { int a[100]; for (int x=0; x<100; x++) a[x]=x*x; for (int y=0; y<100; y++) a[y] = y*y; return 0;}

VB

C#

COBOL

0010 1100 0101 10101100 0011 1111 0101 1010 0101 0000 00001000 1011 0101 00001111 1100 0100 11010101 1010 1100 0011

0010 1100 0101 10101100 0011 1111 0101 1010 0101 0000 00001000 1011 0101 00001111 1100 0100 11010101 1010 1100 0011

MSILMSIL

CLRCLR

Persistent Systems Private Limitedhttp://www.persistent.co.in

DNA to .NET mappings

• Presentation tier mapping– Web Tier - ASP to ASP.NET– Rich client – Win32API to WinForms

• Middle tier mapping– Components – COM to .NET– Connectivity – DCOM to CLR Remoting– Connectivity – ADO to ADO.NET

• Language mapping– VB6 to VB.NET– C++ to C#

Persistent Systems Private Limitedhttp://www.persistent.co.in

Presentation tier mapping

• ASP to ASP.NET

ASP ASP.NET

Interpreted code Compiled code

Inline code/presentation Separate code behind

VBScript and JavaScript VB.NET, C#, COBOL.NET, …

User managed session state Built in session state

Access to limited API Access to entire Framework

Registration required to deploy site Simple xcopy or FTP upload can handle deployment

Changes require web server restart or OS reboot

Config changes are automatically detected and applied

Persistent Systems Private Limitedhttp://www.persistent.co.in

Migration issues

• ASP.NET requires IIS5• No migration tools available from ASP to ASP.NET• ASP and ASP.NET co-exist

– Application/Session variables not shared– Global.asa vs. Global.asax

Persistent Systems Private Limitedhttp://www.persistent.co.in

Rich Client Migration

• Existing frameworks– C++/MFC library– Visual BASIC UI

• .NET “Smart” client– Unified Windows Form– RAD environment

• Migration– VB to VB.NET Wizard– No migration from MFC to WinFrom

Persistent Systems Private Limitedhttp://www.persistent.co.in

Recommendations

• C++– C++/MFC/ALT does not have a migration wizard. – Managed extension and new web service consumer capabilities

can be used

• VB– Upgrade wizard converts most of the code– Watch out for unsupported features like Dynamic Data Exchange,

OLE Containers etc.

Persistent Systems Private Limitedhttp://www.persistent.co.in

Rich client benefits

• Managed code makes application more robust• Utilizes unified framework libraries across languages• Inherent support for ADO.NET and web services

Persistent Systems Private Limitedhttp://www.persistent.co.in

Middle tier components

• COM Component– 2 levels of support - VB and C++/ATL– Registry complexities

• .NET Component– Multiple language support – CLR– Self contained – no dependencies

• Migration– Source level migration – VB.NET– Backward and forward compatibility between COM and .NET

Persistent Systems Private Limitedhttp://www.persistent.co.in

DCOM Migration

• DCOM – Proprietary protocol– Is not internet friendly

• .NET Remoting– Based on standard protocol– Completely flexible and configurable– Supports multiple invocation mechanism

• Migration– .NET uses DCOM protocol for backward compatibility

Persistent Systems Private Limitedhttp://www.persistent.co.in

ADO to ADO.NET

• ADO– COM based connectivity model– Specification for interpreted environment– Always connected scenario

• ADO.NET– Common specs for .NET– XML based dataset model– Disconnected scenario

• Migration– Backward compatibility to ADO– ADO and ADO.NET can co-exist

Persistent Systems Private Limitedhttp://www.persistent.co.in

Language Migration

• VB to VB.NET– Wizard based– Developer review required

• C++ to C++.NET– Managed extension– Native + managed code– No wizard migration

• C++ to C#– Complete rewrite required– Fully Managed code– Unsafe option

Persistent Systems Private Limitedhttp://www.persistent.co.in

Migration strategies

• Partial web front migration– Migrating Web front end while retaining business logic component

• Rich client migration– Migrating Rich client to WinForms while retaining DCOM

compatibilities

• Language level migration– Using available wizards to migrate to .NET component from COM

components

Persistent Systems Private Limitedhttp://www.persistent.co.in

Partial web front migration

COM

COM

COM

IIS

ASP

IIS

ASP

• Retain COM components• Upgrade ASP to ASP.NET• COM interop performance penalty

Persistent Systems Private Limitedhttp://www.persistent.co.in

Rich client migration

Win32 App

.NET Winfrom

COM

COM

COM

• Retain COM components• UpgradeWin32 to Winform• COM interop performance penalty

Persistent Systems Private Limitedhttp://www.persistent.co.in

COM to .NET migration

COM

.NET

VB to VB.NET Wizard migration

C++ to managed C++.NET

Manual C++ to C# rewrite

• Migrate business logic• Partial or complete rewrite• Increased testing/debugging cycle

Persistent Systems Private Limitedhttp://www.persistent.co.in

Another way to look at it…

COM

COM

COM

VB6 Front End

Component Access

Persistent Systems Private Limitedhttp://www.persistent.co.in

Expose Your COM Components …

COM

COM

COM

SOAP

External Apps

VB 6

Web Service

Persistent Systems Private Limitedhttp://www.persistent.co.in

Convert Front End …

COM

COM

COM

SOAP

VB 6

VB.NET

VB 6

COM Interop

Upgrade Tool

Web Service

External Apps

Persistent Systems Private Limitedhttp://www.persistent.co.in

Convert COM to .NET …

.NET .NET .NET

COM

COM

COM

VB.NET Migration Tool

Persistent Systems Private Limitedhttp://www.persistent.co.in

Convert Fully …

VB.NET

VB 6

.NET Interop

Web Service

External Apps

.NET .NET .NET

Persistent Systems Private Limitedhttp://www.persistent.co.in

Migration Notes

• ASP.NET give huge performance improvements over ASP

• Managed code (Winform, BL Components) are more robust then Win32/COM

• Everything need not be migrated at once• Migration can be carried out in phases• Post migration, application can be extended for different

interface e.g. Mobile forms, web service, compact framework etc.

Persistent Systems Private Limitedhttp://www.persistent.co.in

Useful Links

http://www.microsoft.com/nethttp://www.gotdotnet.com

http://www.sharpdevelop.orghttp://www.go-mono.com

http://www.icsharpcode.net

http://www.ecma.ch (C# & CLI standard)

http://www.dotnet247.com/

top related