You are previewing Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET.
O'Reilly logo
Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET

Book Description

  • Find out how to migrate your legacy software to the powerful Microsoft .NET framework

  • Provides for a complete, efficient, and elegant migration—with no surprises

  • Covers the technologies you need: Visual Basic, Visual C++, and Active Server Pages

Move to .NET—and bring your legacy apps along!

Microsoft's .NET Web services platform offers a wide range of exciting new programming opportunities. The new methods found in .NET also mean you'll be in for a lot of aggravation and wasted time—unless you have a proven migration plan in place for your legacy applications. In Migrating to .NET, subject experts Dhananjay Katre, Prashant Halari, Narayana Rao Surapaneni, Manu Gupta, and Meghana Deshpande guide you every step of the way, from planning to migration to follow-through.

  • Migrate legacy Visual Basic, Visual C++, and ASP applications to .NET

  • Draws on the real-world experience of .NET migration experts

  • Rich with code examples and case studies

  • Covers component migration and interoperability issues

Part of the integrated .NET series from Object Innovations and Prentice Hall PTR.

Table of Contents

  1. Copyright
    1. Dedication
  2. The Integrated .NET Series from Object Innovations and Prentice Hall PTR
  3. About Prentice Hall Professional Technical Reference
  4. Preface
    1. Audience for This Book
    2. Acknowledgments
  5. The Integrated .NET Series from Object Innovations and Prentice Hall PTR
    1. Introduction
    2. .NET Programming Books
      1. Introductory .NET Language Books
        1. Introduction to C# Using .NET
        2. Introduction to Visual Basic Using .NET
        3. Programming Perl in the .NET Environment
      2. Intermediate .NET Framework Survey Books
        1. Application Development Using C# and .NET
        2. Application Development Using Visual Basic and .NET
        3. .NET Architecture and Programming Using Visual C++
      3. .NET Applications and Technology
        1. Fundamentals of Web Applications Using .NET and XML
        2. .NET Security and Cryptography
        3. Mobile Application Development Using .NET
        4. Developing Windows Applications Using Visual Basic .NET
        5. Developing Web Applications Using ASP.NET and VB.NET
    3. .NET Interoperability and Migration
      1. Migrating to .NET: A Pragmatic Path to VB.NET, Visual C++ .NET, and ASP.NET
      2. The .NET and COM Interoperability Handbook
      3. XML: Programming Using .NET and Java
  6. 1. Microsoft .NET Framework
    1. Need for .NET Framework
    2. Building Blocks of .NET
      1. The .NET Framework Features
      2. Visual Studio .NET
      3. NET Enterprise Servers
      4. Microsoft .NET Building Block Services
    3. Introduction to Microsoft .NET Framework
      1. Introduction to the CLR
      2. Introduction to the CTS
      3. Introduction to the CLS
      4. Understanding Compilation in .NET Framework
    4. Additional Concepts in .NET Framework
      1. Introduction to Namespaces
      2. Understanding Assemblies in the .NET Framework
      3. Introduction to Managed and Unmanaged Code
    5. Consideration for Migration
    6. Roadmap to Migration
    7. Phases Involved in Migration
      1. Phase I—Assessment
      2. Phase II—Reverse Engineering
      3. Phase III—Forward Engineering
      4. Phase IV—Installation and Release
    8. Summary
  7. 2. New Features in Visual Basic .NET
    1. Visual Basic .NET Features
    2. Object-Oriented Features of Visual Basic .NET
    3. Structured Exception Handling
    4. Threading Features
    5. Language Interoperability
    6. Summary
  8. 3. Visual Basic to Visual Basic .NET Migration Approach
    1. Road Map to Migration
    2. Assessment
    3. Pre-migration Changes Overview
    4. Upgrade Wizard Overview
    5. Post-migration Changes Overview
      1. Pre-migration Recommendations
    6. Understanding Language and Syntax Changes
      1. Variant
      2. Currency
      3. Date
      4. Fixed-Length Strings
      5. Type
      6. Empty
      7. Null and Null Propagation
      8. Def<Type>
      9. Scope of Local Variables
      10. Object Finalization
      11. Arrays
      12. ReDim
      13. Error Handling
      14. Function Return Values
      15. Assignment
      16. Calling Procedures
      17. Static Procedures
      18. Parameter Passing
      19. Optional Parameters
      20. ParamArray Parameters
      21. As Any
      22. Implements
      23. Property Access
      24. Default Properties
      25. Enumerations
      26. While Statement
      27. On..GoTo and On..GoSub
      28. GoSub Return
      29. LSet Statement
      30. VarPtr, StrPtr, and ObjPtr
      31. File Handling
      32. Resource Files
      33. Visual Basic Forms
      34. Caption Property
      35. Fonts
      36. Control Arrays
      37. WebClasses
      38. ActiveX Documents
    7. Understanding the Data Type Changes
    8. Steps for Pre-migration Changes
    9. Upgrade Wizard in Visual Studio .NET
      1. Upgrading a Visual Basic 6.0 Project
      2. Upgrade Report
        1. COMPILE ERRORS
        2. DESIGN ERRORS
      3. Warnings
      4. Performance of the Upgrade Wizard
    10. Summary
  9. 4. Post-migration Changes
    1. Categorization By Functionalities
    2. Graphics
      1. Basics of Graphics
        1. CODE EXAMPLES
          1. Example 1. PictureBox (PaintPicture)
          2. Example 2. PictureBox (FillColor and FillStyle)
          3. Example 3. PictureBox (DrawWidth)
          4. Example 4. PictureBox (AutoRedraw)
          5. Example 5. Command Button (DisabledPicture Property)
          6. Example 6. Command Button (DownPicture Property)
          7. Example 7. FloodFill Method
    3. Dynamic Data Exchange
      1. Example 8. An example of DDE in action
    4. Object Linking and Embedding
      1. WebBrowser Control
    5. Help Functionality
    6. Database Changes
      1. Example 9
      2. Example 10
    7. Drag and Drop Changes
      1. CODE EXAMPLES
        1. Example 11
        2. Example 12
    8. Menu Object Changes
      1. CODE EXAMPLES
        1. Example 13
        2. Example 14
    9. Multiple-Document Interface Form Changes
      1. CODE EXAMPLES
        1. Example 15
        2. Example 16
    10. Controls Collection Changes
      1. CODE EXAMPLES
        1. Example 17
    11. Win32 API Calls
      1. CODE EXAMPLES
        1. Example 18
    12. Designers
      1. CODE EXAMPLES
        1. Example 19
    13. COM+ Components
      1. Code Examples
    14. Summary
  10. 5. Migration Approach for ASP to ASP.NET
    1. Need for a New Version
      1. Use of Scripting Languages
      2. Inline Code
      3. Browser Dependency
      4. Deployment of COM Components
      5. Debugging ASP Applications
    2. Why Migrate to ASP.NET
      1. Compiled Environment
      2. Multiple Language Support
      3. Code Separation
      4. ASP.NET Server Controls
        1. INTRINSIC CONTROLS
        2. WEB SERVER CONTROLS
        3. LIST CONTROLS
        4. RICH CONTROLS
        5. VALIDATION CONTROLS
        6. MOBILE CONTROLS
      5. Browser and Device Independence
      6. Interoperability with Existing COM Components
      7. Configuration
      8. Deployment
      9. Security
      10. State Management
      11. Data Access
      12. Error Handling and Debugging Techniques
      13. Caching
    3. Migration Approach
    4. Considerations for Migration
      1. Selecting an Application for Migration
        1. APPLICATION REQUIREMENTS FOR SCALABILITY AND PERFORMANCE
        2. APPLICATION ARCHITECTURE
        3. NATURE OF CODE
      2. Selecting an Approach for Migration
        1. HORIZONTAL APPROACH
        2. VERTICAL APPROACH
    5. Pre-migration Strategy
      1. Guidelines for Code Changes
      2. Security Settings
        1. MAKING CHANGES TO IIS SECURITY SETTINGS
        2. MAKING CHANGES TO SYSTEM SECURITY SETTINGS
        3. CONFIGURING PROCESS IDENTITY
    6. Summary
  11. 6. Migrating to ASP.NET I
    1. Creating an ASP.NET Web Application
    2. Categorization by Functionality
      1. Web Form Server Controls
        1. INTRINSIC CONTROLS
      2. Data Access
      3. Error Handling and Debugging Techniques
        1. USING ON ERROR STATEMENTS
        2. USING CUSTOM ERROR PAGES
        3. STRUCTURED EXCEPTION HANDLING
      4. Tracing and Debugging
      5. Interoperability in .NET
        1. USING COM IN MANAGED CODE
          1. Consuming the assembly in a .NET Client
        2. USING .NET COMPONENTS IN UNMANAGED CODE
          1. Using the .NET Component
    3. Summary
  12. 7. Migrating to ASP.NET II
    1. Session State Management
      1. Modes
      2. Cache Control
        1. PAGE OUTPUT CACHING
        2. CACHE OBJECT
        3. PREVENTING CACHING
        4. PARTIAL CACHING
    2. Intrinsic Objects
      1. Application Object
      2. Request Object
      3. Response Object
      4. Server Object
      5. ASPError Object
      6. Session Object
    3. Structural Changes
      1. Code Blocks
      2. Render Functions
      3. Use of Scripting Languages
      4. New Page Directives
    4. Language Changes
      1. Variable Declaration
      2. Property Declaration
      3. Create Objects
      4. Method Calls
      5. Parameter Arguments
      6. Default Properties
    5. Summary
  13. 8. New Features in Visual C++ .NET
    1. Managed Extensions
      1. __gc
      2. __value
      3. __abstract
      4. __box
      5. _unboxing
      6. __delegate
      7. __event
      8. __identifier
      9. __interface
      10. __pin
      11. __property
      12. __sealed
      13. __typeof
        1. CUSTOM ATTRIBUTES
      14. Operator overloading
      15. String literal
        1. OBJECT CONSTRUCTION/DESTRUCTION
      16. Finalization
      17. __gc pointers
      18. Pinning Pointers
    2. Platform Invoke
    3. Web Services
      1. ATL Server
      2. ATL Server Web Services
      3. Managed C++ Web Services
        1. ENTRY POINT FOR THE WEB SERVICE
        2. HELPER CLASSES FOR A WEB SERVICE
        3. MAKING A SERVICE AVAILABLE TO THE REMOTE CLIENT
        4. SHARED MFC CLASSES
        5. GDI+
        6. ATL CONTAINER CLASSES
        7. TYPE-SAFE MESSAGE MAPS
        8. THREAD POOLS
        9. PERFORMANCE COUNTERS
        10. SECURITY CLASSES
    4. Summary
  14. 9. Migrating to Visual C++ .NET
    1. Exception Handling
      1. Exception Handling in Managed Extensions
      2. Throwing Exceptions in Managed Code Using Managed Extensions
      3. Try and Catch Blocks in Managed Extensions
      4. __finally Keyword
      5. Catching Unmanaged Exceptions
    2. Migration Strategies for Exception Handling
      1. Disassociated Rethrows
    3. Interoperability
    4. COM Migration
    5. COM Interoperability
      1. Exposing COM Components to the .NET Client
        1. TLBIMP.EXE UTILITY
        2. CLR SUPPORT FOR COM OBJECTS
        3. EARLY BINDING TO COMCOMPONENTS
        4. LATE BINDING TO COM COMPONENTS
        5. RELEASE OF COM OBJECTS
      2. Code Sample
      3. Exposing .NET Components to the COM Client
      4. Shared Name Key Files
    6. Registering the Assembly with COM
    7. Making the Components Accessible
    8. Building the .NET Component
      1. Defining the COM Creatable Class
      2. Code Sample
    9. Migrating an Existing C++ Class to .NET Framework
      1. Migrating a Template Class
      2. Migrating Overloaded Constructors
      3. Supporting Copy Constructor and Assignment Operator
      4. Migrating Accessor (Get/Set) Methods
    10. Summary
  15. 10. Dealing with Legacy Components in .NET
    1. What Defines Code Reusability
      1. Usage Across Different Programming Languages
      2. Case Study
        1. ISSUES
      3. Usage Across Different Systems, Devices, and Environments
      4. Integration and Extensibility for Present and Future Models
    2. Important Features of .NET
    3. The Drawbacks of COM
    4. COM Versus .NET Components
    5. Need for Interoperability between .NET and COM
    6. Managed Environment Versus Unmanaged Environment
    7. Exposing COM Components to .NET Framework
      1. Approach 1 (Using the Command Line)
      2. Approach 2 (Using Visual Studio .NET)
    8. Exposing .NET Components to COM Clients
      1. Approach 1 (Using the Command Line)
      2. Approach 2 (Using Visual Studio .NET)
    9. Summary
  16. 11. Exposing Legacy Components as Web Services
    1. Using Microsoft SOAP ToolKit
    2. Consuming Web Services
      1. Using SOAPClient
      2. Using .NET Client
      3. .NET Web Services
        1. CREATING A WEB SERVICE USING VISUAL STUDIO .NET
        2. CONSUMING WEB SERVICES USING VISUAL STUDIO .NET
    3. Summary
  17. 12. Visual Basic .NET Migration Case Study
    1. Introduction to PMS
      1. Maintaining Stock Information
      2. Maintaining Customer Information
      3. Stock Selling and Purchasing
      4. Maintaining Customer Portfolio
      5. Assumptions
      6. System Flow and Architecture
      7. Database in the System
      8. Setting Up PMS in Visual Basic 6.0
      9. Technical Features Used in the System
    2. Front End for the System
    3. Components in PMS
      1. VBLoginCom
      2. VBStockServiceCom
      3. VBBuySellCom
      4. VBAdminCom
      5. VBReportsCOM
    4. Reports in PMS
    5. Migration of Visual Basic Application
    6. Architecture of the Migrated PMS System
      1. Stock Services Component
      2. Login COM Component
      3. Admin COM Component
      4. Reports COM Component
      5. BuySell COM Component
    7. Summary
  18. 13. Case Study: ASP to ASP.NET
    1. ASP Web Application
      1. Architecture
      2. Customer Module
      3. Admin Module
    2. Migrating the Application
      1. Architecture
      2. Customer Module
      3. Migrating VBLoginCOM
      4. Exposing VBBuySellCOM as Web Service
      5. Admin Module
    3. Summary
  19. 14. Visual C++ .NET Migration Case Study
    1. Setting Up PMS in Visual C++ 6.0
    2. Front End for the System
    3. COM Components in PMS
      1. VCLoginCom
        1. LOGIN: LOGIN(BSTR BSTRUSERID, BSTR BSTRPASSWD, VARIANT *VMESSAGE, INT *IRETVAL)
        2. LOGOUT: LOGOUT(BSTR BSTRUSERID, VARIANT *VMESSAGE, INT *IRETVAL)
        3. CHANGEPASSWORD: CHANGEPASSWORD(BSTR BSTRUSERID, BSTR BSTROLDPASSWD, BSTR BSTRNEWPASSWD, VARIANT *VMESSAGE, INT *IRETVAL)
      2. VCStockServiceCom
        1. GETSTOCKPRICES: GETSTOCKPRICE(VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVAL)
      3. VCOrderCom
        1. EXECUTEORDER: EXECUTEORDER(BSTR BSTRCUSTID, BSTR BSTRSTOCKID, FLOAT FSTOCKPRICE, INT IQUANTITY, BSTR BSTRBUYSELL, VARIANT *VMESSAGE, INT *IRETVALUE)
      4. VCAdminCom
        1. LOGIN: LOGIN(BSTR BSTRUSERID, BSTR BSTRPASSWD, VARIANT *VMESSAGE, INT *IRETVAL)
        2. CHANGE PASSWORD: CHANGEPASSWORD(BSTR BSTRUSERID, BSTR BSTROLDPASSWD, BSTR BSTRNEWPASSWD, VARIANT *VMESSAGE, INT *IRETVAL)
        3. ADDCUSTOMER: ADDCUSTOMER(BSTR BSTRUSERID, BSTR BSTRPASSWD, BSTR BSTRNAME, BSTR BSTRADDRESS, DOUBLE DBLPHONE, BSTR BSTREMAIL, FLOAT FMARGIN, FLOAT FMINAMOUNT, VARIANT *VMESSAGE, INT *IRETVAL)
        4. UPDATECUSTOMER: UPDATECUSTOMER(BSTR BSTRUSERID, BSTR BSTROLDPASSWD, BSTR BSTRNEWPASSWD, BSTR BSTRNAME, BSTR BSTRADDRESS, DOUBLE DBLPHONE, BSTR BSTREMAIL, FLOAT FMARGIN, FLOAT FMINAMOUNT, VARIANT *VMESSAGE, INT *IRETVAL)
        5. GETUNAPPROVEDORDERS: GETUNAPPROVEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
        6. APPROVEORDER: APPROVEORDER(INT IORDERID, VARIANT *VMESSAGE, INT *IRETVALUE)
        7. CANCELORDER: CANCELORDER(INT IORDERID, VARIANT *VMESSAGE, INT *IRETVALUE)
        8. GETCUSTOMERS: GETCUSTOMERS(VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
        9. GETCUSTOMERDETAILS: GETCUSTOMERDETAILS(BSTR BSTRCUSTID, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
        10. REPORTAPPROVEDORDERS: REPORTAPPROVEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
        11. REPORTCANCELLEDORDERS: REPORTCANCELLEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
      5. VCReportsCOM
        1. GETPORTFOLIOINFO: GETPORTFOLIOINFO(BSTR BSTRCUSTID, VARIANT *VCUSTPORTFOLIO, VARIANT *VMESSAGE, INT *IRETVAL)
        2. GETCUSTOMERDETAILS: GETCUSTOMERDETAILS(BSTR BSTRCUSTID, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVAL)
        3. GETSTOCKPERFORMANCE:GETSTOCKPERFORMANCE(BSTR BSTRSTOCKID, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
        4. GETSTOCKS: GETSTOCKS(VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVAL)
        5. GETUNAPPROVEDORDERS: GETUNAPPROVEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
        6. REPORTAPPROVEDORDERS: REPORTAPPROVEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
        7. REPORTCANCELLEDORDERS: REPORTCANCELLEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)
    4. ISAPI DLLs in PMS
    5. CustomerServices DLL
      1. AdminServices DLL
    6. Flow of Information in the PMS
    7. Migration of a Visual C++ Application to Visual C++.NET
      1. StockInfoWebService
      2. SessionsWebService
      3. OrdersWebService
    8. Summary
  20. A. Controls in Visual Basic
    1. App Object
    2. CheckBox Control
    3. Clipboard Object
    4. ComboBox
    5. Command Button
    6. Controls Collections
    7. DirListBox Control
    8. DriveListBox Control
    9. FileListBox Control
    10. Form Object
    11. Frame Control
    12. Hscrollbar
    13. Image Control
    14. Label Control
    15. Line Control
    16. ListBox Control
    17. MDIForm Object
    18. OptionButton
    19. PictureBox Control
    20. Screen Object
    21. Shape Control
    22. TextBox Control
    23. Timer Control
    24. VScrollBar Control
  21. B. Comparison between HTML Controls and Server Controls