Introduction To Dot Net Siddhesh


Published on

High level introduction to .NET

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Introduction To Dot Net Siddhesh

  1. 1. Introduction to .NET Siddhesh Bhobe
  2. 2. Agenda <ul><li>What is .NET? </li></ul><ul><li>.NET framework and building blocks </li></ul><ul><li>ADO.NET </li></ul><ul><li>Web Services in .NET </li></ul><ul><li>DNA to .NET Migration </li></ul>
  3. 3. What is Microsoft .NET? <ul><li>From the Microsoft site: </li></ul><ul><li>“ 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.” </li></ul><ul><li>.NET includes: </li></ul><ul><li>The .NET Platform , which is a set of programming tools and infrastructure to enable the creation, deployment, management, and aggregation of XML Web services. </li></ul><ul><li>.NET experiences (applications!) , which are the means for end users to interact with .NET. </li></ul>
  4. 4. The .NET Platform <ul><li>NET Framework and Visual Studio .NET </li></ul><ul><li>Server infrastructure </li></ul><ul><ul><li>Application Center 2000; </li></ul></ul><ul><ul><li>BizTalk™ Server 2000; </li></ul></ul><ul><ul><li>Host Integration Server 2000; </li></ul></ul><ul><ul><li>Mobile Information 2001 Server; and </li></ul></ul><ul><ul><li>SQL Server™ 2000 </li></ul></ul><ul><li>Building block services </li></ul><ul><ul><li>They include Passport (for user identification) and services for message delivery, file storage, user-preference management, calendar management, and other functions. </li></ul></ul><ul><li>Smart Devices </li></ul><ul><ul><li>Enables PCs, laptops, workstations, smart phones, handheld computers, Tablet PCs, game consoles, and other smart devices to operate in the .NET universe. </li></ul></ul>
  5. 5. The .NET Framework
  6. 6. 1 st generation web applications OS Services Microsoft provided IIS, IE and COM Applications largely operating in a client / server model were augmented with web browser and servers. Browsers Web app developers took advantage of these local services and used HTML to “project” the UI to many types of clients. Servers Data, Hosts UI Logic Biz Logic
  7. 7. 2 nd generation of web applications Combination of “stateless” Web protocols with DNS and IP routing have enabled mass-scale “Geo-Scalability” “ Stateful” “ Stateless” & “ Geo-Scalable” OS Services Biz Logic Tier Rich Client UI Logic Servers Data, Hosts Richer Browsers 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.
  8. 8. Next Generation Applications Richer, More Productive User Experience Applications Become Programmable Web Services Standard Browsers Open Internet Communications Protocols (HTTP, SMTP, XML, SOAP) Applications Leverage Globally-Available Web Services Smarter Clients Smarter Devices OS Services Biz Tier Logic Biz Logic & Web Service OS Services Public Web Services Building Block Services Internal Services XML XML XML Servers Data, Hosts XML Other Services XML XML XML HTML
  9. 9. Development/Deployment headaches <ul><li>Non-consistent programming model </li></ul><ul><li>Knowledge of plumbing code </li></ul><ul><li>DLL management issues –’DLL HELL’ </li></ul><ul><li>Resource management </li></ul><ul><li>Non-consistent error handling </li></ul><ul><li>Deployment issues </li></ul><ul><li>Security </li></ul>
  10. 10. Couldn’t we have this! No “plumbing” is needed and objects can directly interact Components are built on a “common” substrate.
  11. 11. Couldn’t we have this! <ul><li>Enables shared services: </li></ul><ul><ul><li>GC, exception handler, security, threading, debugging… </li></ul></ul>
  12. 12. Couldn’t we have this! <ul><li>Common API: </li></ul><ul><ul><li>IO, Collections, XML, UI… </li></ul></ul><ul><li>… across all languages </li></ul>
  13. 13. How Much Simpler? HWND hwndMain = CreateWindowEx( 0, &quot;MainWClass&quot;, &quot;Main Window&quot;, 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 = &quot;Main Window&quot;; form.Show(); Windows API .NET Framework
  14. 14. Architecture Visual Studio.NET Windows COM+ Services Common Language Runtime Base Class Library ADO.NET and XML ASP.NET Windows Forms Common Language Specification VB C++ C# JScript …
  15. 15. Common Language Runtime VB Source code Compiler C++ C# Compiler Compiler Assembly IL Code Assembly IL Code Assembly IL Code Operating System Services Common Language Runtime JIT Compiler Native Code Managed code Unmanaged Component
  16. 16. Compilation Source Code C++, C#, VB or any .NET language Metadata IL Managed code Resources myprogram.DLL Assembly is basic deployable unit in .NET VS.NET Csc.exe, vbc.exe, etc. Compiler Assembly DLL or EXE
  17. 17. Assemblies The Building Block <ul><li>Deployment unit for types and resources: a “logical dll” </li></ul><ul><li>Self describing through a manifest </li></ul><ul><li>Fundamental unit of versioning, reuse, deployment and permission grants and requests </li></ul>
  18. 18. ADO.NET
  19. 19. ADO.NET Architecture OdbcConnection OdbcCommand OdbcDataAdapte r Odb cDataReader ODBC .NET Data Provider COM Inter op ODBC
  20. 20. ADO.NET
  21. 21. Making Database Connection <ul><li>Using SQL Server .NET data provider. </li></ul><ul><li>SqlConnection connSql=new SqlConnection (&quot;Address=dotsrv;uid=sa;pwd=sql;connect Timeout=5;&quot;); </li></ul><ul><li>Using OLEDB.NET Provider to connect to Oracle </li></ul><ul><li>OleDbConnection connOle=new OleDbConnection (&quot;Provider=OraOLEDB.Oracle.1;Data Source=_CRUISEDB; user id=xat;password=xat;&quot;); </li></ul><ul><li>Using ODBC.NET Provider to connect to Oracle </li></ul><ul><li>OdbcConnection connODBC=new OdbcConnection (&quot;DSN=connectOra;Server=_CRUISEDB;uid=xat;pwd=xat;&quot;); </li></ul>
  22. 22. ADO and XML in the .NET Framework Managed Provider DataReader Command Connection Sync Controls, Designers, Code-gen, etc DataSet XmlReader XSL/T, X-Path, etc XmlData- Document DataAdapter
  23. 23. DataSet <ul><li>Relational View of Data </li></ul><ul><ul><li>Tables, Columns, Rows, Constraints </li></ul></ul><ul><ul><li>Navigate between tables using Relations </li></ul></ul><ul><ul><ul><li>DataRow[] orders = customer.GetChildren(&quot;custOrd&quot;); </li></ul></ul></ul><ul><li>Source-agnostic </li></ul><ul><ul><li>XML, Relational, Application data </li></ul></ul><ul><li>Remotable </li></ul><ul><ul><li>No knowledge of source of data </li></ul></ul><ul><ul><li>Never holds connection state </li></ul></ul><ul><ul><li>DataSet as argument to WebMethods </li></ul></ul><ul><ul><ul><li>Serializes as XML Schema/Data </li></ul></ul></ul>DataSet Tables Table Columns Column Constraints Constraint Rows Row Relations Relation
  24. 24. Example: Reading/Writing XML <ul><li>// Load DataSet with XML </li></ul><ul><li>DataSet ds = new DataSet(); </li></ul><ul><li>ds.ReadXml(&quot;inventory.xml&quot;); </li></ul><ul><li>// Add a record to the Inventory table </li></ul><ul><li>DataTable inventory = ds.Tables[&quot;Inventory&quot;]; </li></ul><ul><li>DataRow row = inventory.NewRow(); </li></ul><ul><li>row[&quot;TitleID&quot;]=1; </li></ul><ul><li>row[&quot;Quantity&quot;]=25; </li></ul><ul><li>inventory.Rows.Add(row); </li></ul><ul><li>// Write out XML </li></ul><ul><li>ds.WriteXml(&quot;updatedinventory.xml&quot;); </li></ul>
  25. 25. Example: Associating an XmlDataDocument with a DataSet <ul><li>private static XmlDataDocument xmlData; </li></ul><ul><li>public static DataSet LoadDataSet(String schema) { </li></ul><ul><li>DataSet ds = new DataSet(); </li></ul><ul><li>ds.ReadXmlSchema(schema); </li></ul><ul><li>xmlData = new XmlDataDocument(ds); </li></ul><ul><li>xmlData.Load(&quot;po.xml&quot;); </li></ul><ul><li>return ds; </li></ul><ul><li>} </li></ul><ul><li>public static void SaveChanges() { </li></ul><ul><li>xmlData.Save(&quot;po.xml&quot;); </li></ul><ul><li>} </li></ul>
  26. 26. Example: X/Path over Relational <ul><li>public static void doXml(DataSet po) { </li></ul><ul><li>// Associate an XmlDataDocument with the DataSet </li></ul><ul><li>XmlDataDocument xmlData = new XmlDataDocument(po); </li></ul><ul><li>// Do an X/Path Query </li></ul><ul><li>XmlNodeList nodes = xmlData.SelectNodes(&quot;//Item[@qty>100]&quot;); </li></ul><ul><li>// Write out results </li></ul><ul><li>Console.WriteLine(&quot;Matches=&quot;+nodes.Count); </li></ul><ul><li>foreach(XmlNode node in nodes) { </li></ul><ul><li> DataRow row = </li></ul><ul><li>xmlData.GetRowFromElement((XmlElement)node); </li></ul><ul><li> // Mark Customer for Deletion </li></ul><ul><li> row.Delete(); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  27. 27. Example: XSL/T over Relational <ul><li>public static void doTransform(DataSet po) { </li></ul><ul><li>XmlDataDocument xmlData = new XmlDataDocument(po); </li></ul><ul><li>// Do a Transform </li></ul><ul><li>XslTransform xsltransform = new XslTransform(); </li></ul><ul><li>xsltransform.Load(&quot;po.xsl&quot;); </li></ul><ul><li>XmlReader xReader = xsltransform.Transform(xmlData, null); </li></ul><ul><li>} </li></ul>
  28. 28. Summary <ul><li>ADO.NET provides a model for bridging the gap between XML and Relational data </li></ul><ul><ul><li>DataSet provides Relational View </li></ul></ul><ul><ul><ul><li>Persists/loads data as XML </li></ul></ul></ul><ul><ul><ul><li>Persists/loads schema as XSD </li></ul></ul></ul><ul><ul><ul><li>Serializes as XML with in-line schema </li></ul></ul></ul><ul><ul><li>XmlDataDocument provides an XML view </li></ul></ul><ul><ul><ul><li>Exposes relational data to XML tools </li></ul></ul></ul><ul><ul><ul><li>Exposes a relational subset of XML data </li></ul></ul></ul><ul><ul><ul><li>Preserves Fidelity of XML </li></ul></ul></ul>
  29. 29. Web Services in .NET
  30. 30. Web Services are “Key” in .NET
  31. 31. Web Services Infrastructure in .NET <ul><li>IIS and COM+ provides the hosting environment </li></ul><ul><li>APIs </li></ul><ul><ul><li>COM for implementing the business façade, business logic, and data access layers </li></ul></ul><ul><ul><li>ADO, OLE DB, and ODBC for implementing data access to a variety of data stores </li></ul></ul><ul><ul><li>MSXML to help construct and consume XML messages in the Web Service listener </li></ul></ul><ul><ul><li>Active Server Pages (ASP) or ISAPI for implementing the Web Service listener </li></ul></ul><ul><li>NLBS and Clustering for scalability </li></ul><ul><li>IPSec, HTTP Basic authentication, Digest authentication, Kerberos 5 authentication, NTLM authentication, or your own custom scheme. </li></ul>
  32. 32. .NET Web Services Infrastructure <ul><li>Smart Clients and Devices to consume Web Services </li></ul><ul><li>Suite of .NET Servers, including Win 2K family and .NET Enterprise Servers </li></ul><ul><li>Development Tools </li></ul><ul><ul><li>VS.NET </li></ul></ul><ul><ul><ul><li>Single unified IDE for all languages </li></ul></ul></ul><ul><ul><ul><li>Enable applications as Web Services </li></ul></ul></ul><ul><ul><ul><li>Aggregate Web Services </li></ul></ul></ul><ul><ul><li>.NET Framework </li></ul></ul><ul><ul><ul><li>Build, deploy and run Web Services </li></ul></ul></ul>
  33. 33. Service Description <ul><li>Uses WSDL to describe itself </li></ul><ul><li>Uses namespaces to uniquely identify service endpoints </li></ul><ul><li>Server-side component that map Web Services to COM components using WSDL and Web Services Meta Language (WSML) description </li></ul>
  34. 34. Service Implementation <ul><li>Several languages running on Common Language Infrastructure: VB.NET, C#, JScript </li></ul><ul><li>SOAP Toolkit for constructing, transmitting, reading and processing SOAP messages </li></ul>
  35. 35. Service Publishing, Discovery and Binding <ul><li>Used to have DISCO for discovering Web Services </li></ul><ul><li>Now supports UDDI </li></ul><ul><li>Provides .NET UDDI server </li></ul><ul><li>Office XP offer support for service discovery through UDDI </li></ul>
  36. 36. Service Invocation and Execution <ul><li>Use of built-in .NET SOAP message classes </li></ul><ul><li>Construct Web Service listeners using MSXML, ASP, ISAPI etc </li></ul><ul><li>Use SOAP toolkit to build a Web Service listener </li></ul><ul><li>Client-side components for invoking Web Services </li></ul>
  37. 37. Creating and Consuming Web Services in VS.NET
  38. 38. Create New ASP.NET Web Service Project
  39. 39. Project and Sample Files created
  40. 40. Add New Web Service to the Project
  41. 41. default.asmx <ul><li><%@ WebService Language =&quot;vb&quot; Codebehind =&quot;default.asmx.vb&quot; Class =&quot;DegreesWebService._default&quot; %> </li></ul>
  42. 42. default.asmx.vb
  43. 43. What makes this a web service? <ul><li>&quot;Imports System.Web.Services&quot; brings in the functionality needed under this class. </li></ul><ul><li>&quot;<WebService(Namespace := &quot;;)> _&quot; makes this class callable from the web. </li></ul><ul><li>&quot;Inherits System.Web.Services.WebService&quot;, makes this class inherit all the methods and properties of this class. </li></ul><ul><li>&quot;<WebMethod()>&quot; in front of a method makes this callable from the web. </li></ul>
  44. 44. Our Web Service
  45. 45. Building and testing the web service <ul><li>Make sure that our starting page for the project is the default.asmx page </li></ul><ul><li>Then go to Debug > Start , or press F5 . VS builds the project and pops up a web browser window with this file. </li></ul><ul><li>This is simply a medium that Microsoft has provided so that we can test our Web Service. </li></ul>
  46. 46. Testing a web service
  47. 47. Enter Values…
  48. 48. Invoke…
  49. 49. Add Web Reference
  50. 50. Web Reference added
  51. 51. Modified default.aspx
  52. 52. Code behind
  53. 53. More… <ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul>
  54. 54. DNA to .NET Migration
  55. 55. Windows DNA architecture Windows NT 4/Windows 2000 COM COM COM IIS ASP SQL
  56. 56. .NET Framework <ul><li>Common Language Runtime </li></ul><ul><li>Managed data and code </li></ul><ul><li>Unified framework library </li></ul><ul><li>Multiple language support </li></ul>#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; } 0010 1100 0101 1010 1100 0011 1111 0101 1010 0101 0000 0000 1000 1011 0101 0000 1111 1100 0100 1101 0101 1010 1100 0011 MSIL CLR VB C# COBOL
  57. 57. DNA to .NET mappings <ul><li>Presentation tier mapping </li></ul><ul><ul><li>Web Tier - ASP to ASP.NET </li></ul></ul><ul><ul><li>Rich client – Win32API to WinForms </li></ul></ul><ul><li>Middle tier mapping </li></ul><ul><ul><li>Components – COM to .NET </li></ul></ul><ul><ul><li>Connectivity – DCOM to CLR Remoting </li></ul></ul><ul><ul><li>Connectivity – ADO to ADO.NET </li></ul></ul><ul><li>Language mapping </li></ul><ul><ul><li>VB6 to VB.NET </li></ul></ul><ul><ul><li>C++ to C# </li></ul></ul>
  58. 58. Presentation tier mapping <ul><li>ASP to ASP.NET </li></ul>Separate code behind Inline code/presentation Config changes are automatically detected and applied Changes require web server restart or OS reboot Simple xcopy or FTP upload can handle deployment Registration required to deploy site Access to entire Framework Access to limited API Built in session state User managed session state VB.NET, C#, COBOL.NET, … VBScript and JavaScript Compiled code Interpreted code ASP.NET ASP
  59. 59. Migration issues <ul><li>ASP.NET requires IIS5 </li></ul><ul><li>No migration tools available from ASP to ASP.NET </li></ul><ul><li>ASP and ASP.NET co-exist </li></ul><ul><ul><li>Application/Session variables not shared </li></ul></ul><ul><ul><li>Global.asa vs. Global.asax </li></ul></ul>
  60. 60. Rich Client Migration <ul><li>Existing frameworks </li></ul><ul><ul><li>C++/MFC library </li></ul></ul><ul><ul><li>Visual BASIC UI </li></ul></ul><ul><li>.NET “Smart” client </li></ul><ul><ul><li>Unified Windows Form </li></ul></ul><ul><ul><li>RAD environment </li></ul></ul><ul><li>Migration </li></ul><ul><ul><li>VB to VB.NET Wizard </li></ul></ul><ul><ul><li>No migration from MFC to WinFrom </li></ul></ul>
  61. 61. Recommendations <ul><li>C++ </li></ul><ul><ul><li>C++/MFC/ALT does not have a migration wizard. </li></ul></ul><ul><ul><li>Managed extension and new web service consumer capabilities can be used </li></ul></ul><ul><li>VB </li></ul><ul><ul><li>Upgrade wizard converts most of the code </li></ul></ul><ul><ul><li>Watch out for unsupported features like Dynamic Data Exchange, OLE Containers etc. </li></ul></ul>
  62. 62. Rich client benefits <ul><li>Managed code makes application more robust </li></ul><ul><li>Utilizes unified framework libraries across languages </li></ul><ul><li>Inherent support for ADO.NET and web services </li></ul>
  63. 63. Middle tier components <ul><li>COM Component </li></ul><ul><ul><li>2 levels of support - VB and C++/ATL </li></ul></ul><ul><ul><li>Registry complexities </li></ul></ul><ul><li>.NET Component </li></ul><ul><ul><li>Multiple language support – CLR </li></ul></ul><ul><ul><li>Self contained – no dependencies </li></ul></ul><ul><li>Migration </li></ul><ul><ul><li>Source level migration – VB.NET </li></ul></ul><ul><ul><li>Backward and forward compatibility between COM and .NET </li></ul></ul>
  64. 64. DCOM Migration <ul><li>DCOM </li></ul><ul><ul><li>Proprietary protocol </li></ul></ul><ul><ul><li>Is not internet friendly </li></ul></ul><ul><li>.NET Remoting </li></ul><ul><ul><li>Based on standard protocol </li></ul></ul><ul><ul><li>Completely flexible and configurable </li></ul></ul><ul><ul><li>Supports multiple invocation mechanism </li></ul></ul><ul><li>Migration </li></ul><ul><ul><li>.NET uses DCOM protocol for backward compatibility </li></ul></ul>
  65. 65. ADO to ADO.NET <ul><li>ADO </li></ul><ul><ul><li>COM based connectivity model </li></ul></ul><ul><ul><li>Specification for interpreted environment </li></ul></ul><ul><ul><li>Always connected scenario </li></ul></ul><ul><li>ADO.NET </li></ul><ul><ul><li>Common specs for .NET </li></ul></ul><ul><ul><li>XML based dataset model </li></ul></ul><ul><ul><li>Disconnected scenario </li></ul></ul><ul><li>Migration </li></ul><ul><ul><li>Backward compatibility to ADO </li></ul></ul><ul><ul><li>ADO and ADO.NET can co-exist </li></ul></ul>
  66. 66. Language Migration <ul><li>VB to VB.NET </li></ul><ul><ul><li>Wizard based </li></ul></ul><ul><ul><li>Developer review required </li></ul></ul><ul><li>C++ to C++.NET </li></ul><ul><ul><li>Managed extension </li></ul></ul><ul><ul><li>Native + managed code </li></ul></ul><ul><ul><li>No wizard migration </li></ul></ul><ul><li>C++ to C# </li></ul><ul><ul><li>Complete rewrite required </li></ul></ul><ul><ul><li>Fully Managed code </li></ul></ul><ul><ul><li>Unsafe option </li></ul></ul>
  67. 67. Migration strategies <ul><li>Partial web front migration </li></ul><ul><ul><li>Migrating Web front end while retaining business logic component </li></ul></ul><ul><li>Rich client migration </li></ul><ul><ul><li>Migrating Rich client to WinForms while retaining DCOM compatibilities </li></ul></ul><ul><li>Language level migration </li></ul><ul><ul><li>Using available wizards to migrate to .NET component from COM components </li></ul></ul>
  68. 68. Partial web front migration <ul><li>Retain COM components </li></ul><ul><li>Upgrade ASP to ASP.NET </li></ul><ul><li>COM interop performance penalty </li></ul>COM COM COM IIS ASP IIS ASP
  69. 69. Rich client migration <ul><li>Retain COM components </li></ul><ul><li>UpgradeWin32 to Winform </li></ul><ul><li>COM interop performance penalty </li></ul>Win32 App .NET Winfrom COM COM COM
  70. 70. COM to .NET migration <ul><li>Migrate business logic </li></ul><ul><li>Partial or complete rewrite </li></ul><ul><li>Increased testing/debugging cycle </li></ul>VB to VB.NET Wizard migration C++ to managed C++.NET Manual C++ to C# rewrite COM .NET
  71. 71. Another way to look at it… VB6 Front End Component Access COM COM COM
  72. 72. Expose Your COM Components … External Apps VB 6 Web Service COM COM COM SOAP
  73. 73. Convert Front End … VB 6 VB.NET VB 6 COM Interop Upgrade Tool Web Service External Apps COM COM COM SOAP
  74. 74. Convert COM to .NET … VB.NET Migration Tool .NET .NET .NET COM COM COM
  75. 75. Convert Fully … VB.NET VB 6 .NET Interop Web Service External Apps .NET .NET .NET
  76. 76. Migration Notes <ul><li>ASP.NET give huge performance improvements over ASP </li></ul><ul><li>Managed code (Winform, BL Components) are more robust then Win32/COM </li></ul><ul><li>Everything need not be migrated at once </li></ul><ul><li>Migration can be carried out in phases </li></ul><ul><li>Post migration, application can be extended for different interface e.g. Mobile forms, web service, compact framework etc. </li></ul>
  77. 77. Useful Links (C# & CLI standard)