upgrading visual basic 6.0 applications to visual basic ... · upgrading visual basic 6.0...

719
Upgrading Visual Basic 6.0 Applications to Visual Basic .NET and Visual Basic 2005

Upload: vokhanh

Post on 16-Oct-2018

300 views

Category:

Documents


5 download

TRANSCRIPT

  • Upgrading Visual Basic 6.0Applications to Visual Basic .NETand Visual Basic 2005

  • Upgrading Visual Basic 6.0Applications to Visual Basic .NETand Visual Basic 2005

    pat ter ns & pract ices

  • ISBN 0-7356-2298-1

    Information in this document, including URL and other Internet Web sitereferences, is subject to change without notice. Unless otherwise noted, theexample companies, organizations, products, domain names, e-mail addresses,logos, people, places, and events depicted herein are fictitious, and no associationwith any real company, organization, product, domain name, e-mail address, logo,person, place, or event is intended or should be inferred. Complying with allapplicable copyright laws is the responsibility of the user. Without limiting therights under copyright, no part of this document may be reproduced, stored in orintroduced into a retrieval system, or transmitted in any form or by any means(electronic, mechanical, photocopying, recording, or otherwise), or for anypurpose, without the express written permission of Microsoft Corporation.

    Microsoft may have patents, patent applications, trademarks, copyrights, or otherintellectual property rights covering subject matter in this document. Except asexpressly provided in any written license agreement from Microsoft, the furnishingof this document does not give you any license to these patents, trademarks,copyrights, or other intellectual property.

    2005 Microsoft Corporation. All rights reserved.

    Microsoft, MS-DOS, Windows, Windows Mobile, Windows NT, Windows Server,ActiveX, Excel, FrontPage, IntelliSense, JScript, Visual Basic, Visual C++, Visual C#,Visual J#, Visual Studio, and Win32 are either registered trademarks ortrademarks of Microsoft Corporation in the United States and/or other countries.

    ArtinSoft is the registered trademark of ArtinSoft Corporation in the United Statesand/or other countries.

    The names of actual companies and products mentioned herein may be thetrademarks of their respective owners.

  • Contents

    Preface xvWho Should Read This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi

    For Technical Decision Makers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviFor Solution Architects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviFor Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi

    Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviiHow to Use This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

    Relevant Chapters for Technical Decision Makers . . . . . . . . . . . . . . . . . . . . . . . . . . . xxRelevant Chapters for Solution Architects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxRelevant Chapters for Software Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi

    Document Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiFeedback and Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiiPrincipal Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiiContributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiiiAcknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiiiMore Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv

    Chapter 1Introduction 1

    Why Consider an Upgrade Project? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Minimum Information Needed to Make a Decision . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    Upgrade Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Moving from Visual Basic 6.0 to Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    Increased Productivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Better Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Application Extendibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Improved Reliability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Improved Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Improved Deployment Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Increased Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Benefits of the Visual Basic 6.0 to Visual Basic .NET Upgrade Wizard . . . . . . . . . . . 23

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    Chapter 2Practices for Successful Upgrades 25

    Functional Equivalence and Application Advancement . . . . . . . . . . . . . . . . . . . . . . . . . 25Functional Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Application Advancement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

  • Contentsiv

    Organizational Structure and the Software Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . 26Overview of the Upgrade Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Proof of Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Planning the Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    Defining the Project Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Performing an Application Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Assessing the Current and the Target Architectures . . . . . . . . . . . . . . . . . . . . . . . . 33Analyzing and Designing New Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Selecting an Upgrade Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Making an Inventory of Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Preparing the Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Preparing to Handle Upgrade Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    Producing a Project Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Estimating Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Preparing for the Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

    Preparing the Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47Preparing the Visual Basic 6.0 Source Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Upgrading Applications Written in Earlier Versions of Visual Basic . . . . . . . . . . . . . . 50Verifying Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

    Upgrading the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Testing and Quality Assurance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Microsoft Windows Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

    Advancing an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Managing an Upgrade Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    Change Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Managing the Project after Using the Upgrade Wizard . . . . . . . . . . . . . . . . . . . . . . . 59Upgrade Project Complications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63Using Historical Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Best Practices for Performing Your Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Avoiding a Common Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    Chapter 3Assessment and Analysis 69

    Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Project Scope and Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

    Evaluating Upgrade Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Business Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Technical Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Gathering Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81Assessing Application Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81Application Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

  • Contents v

    Application Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Using the Assessment Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Current and Target Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87Inventory to Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Source Code Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90Handling Unsupported Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91Application Dependences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Missing Application Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    Estimating Effort and Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95Methodology Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95Aspects to Be Estimated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97Understanding the Effort Total Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98Understanding the Configuration Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

    Chapter 4Common Application Types 107

    Identifying and Upgrading Application Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107Determining Application Type and Functional Equivalency . . . . . . . . . . . . . . . . . . . 108Determining Component and Project Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

    Desktop and Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109Architecture Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109Desktop Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    Application Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123Native DLLs and Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123Interoperability Between .NET and COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125Reusable Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127ActiveX Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128ActiveX Controls Embedded in Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130ActiveX Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

    Distributed Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132DCOM Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132MTS and COM+ Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

    Chapter 5The Visual Basic Upgrade Process 139

    Procedure Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139Application Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

    Development Environment Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142Upgrade Wizard Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145Removing Unused Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

  • Contentsvi

    Obtaining the Application Resource Inventory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148Compilation Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Project Upgrade Order Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150Determine All Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150Reviewing the Upgrade Wizard Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    Application Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156Execution of the Visual Basic Upgrade Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . 157Verifying the Progress of the Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166Fixing Problems with the Upgrade Wizard Execution . . . . . . . . . . . . . . . . . . . . . . . 166Completing the Upgrade with Manual Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

    Testing and Debugging the Upgraded Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 173Upgrade Report Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173Fixing Run-Time Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

    Chapter 6Understanding the Visual Basic Upgrade Wizard 183

    Using the Upgrade Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183Tasks Performed by the Upgrade Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

    Code Modification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184Reference Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185The Upgrade Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186

    Supported Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187Visual Basic 6.0 Language Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187Visual Basic 6.0 Native Libraries (VB, VBA, VBRUN) . . . . . . . . . . . . . . . . . . . . . . . 203Visual Basic 6.0 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204ActiveX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

    Chapter 7Upgrading Commonly-Used Visual Basic 6.0 Objects 217

    Upgrading the App Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219Upgrading the Screen Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Upgrading the Printer Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226Upgrading the Printers Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233Upgrading the Forms Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235Upgrading the Clipboard Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237Upgrading the Licenses Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240Upgrading the Controls Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

  • Contents vii

    Chapter 8Upgrading Commonly-Used Visual Basic 6.0 Language Features 247

    Resolving Issues with Default Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247Resolving Issues with Custom Collection Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Dealing with Changes to Commonly-Used Functions and Objects . . . . . . . . . . . . . . . . 253Dealing with Changes to TypeOf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255Upgrading References to Visual Basic 6.0 Enum Values . . . . . . . . . . . . . . . . . . . . . . 258

    Defining Your Own Constant Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259Using the Non-Constant Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

    Dealing with Changes to Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261Legacy Visual Basic Language Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264

    Upgrading Add-ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

    Chapter 9Upgrading Visual Basic 6.0 Forms Features 275

    Handling Changes to Graphics Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275Removal of the Line Control in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . 275Removal of the Shape Control in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . 276

    Handling Changes to the PopupMenu Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278Handling Changes to the ClipControls Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279Drag-and-Drop Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

    Drag-and-Drop Functionality in Visual Basic 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . 280Drag-and-Drop Functionality in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . 282

    Handling Changes to the MousePointer and MouseIcon Properties . . . . . . . . . . . . . . 286Handling Changes to Property Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288Handling Changes to the OLE Container Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292Handling Changes to Control Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

    Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295Accessing Control Arrays as a Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296Adding Controls Dynamically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

    Handling Changes to DDE Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

    Chapter 10Upgrading Web Applications 301

    Upgrading ActiveX Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302Upgrading Web Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306

  • Contentsviii

    Chapter 11Upgrading String and File Operations 307

    Operations Handled by the Upgrade Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307Auto-Upgraded String Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308Auto-Upgraded File Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

    Manual String and File Operation Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313Replacing Strings with StringBuilders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313Replacing Complex String Manipulation with Regular Expressions . . . . . . . . . . . . . 314Improving File I/O with Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317File Access Through the File System Object Model . . . . . . . . . . . . . . . . . . . . . . . . 319

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

    Chapter 12Upgrading Data Access 323

    General Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324ActiveX Data Objects (ADO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

    Upgrading ADO Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325Projects without ADO Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327Upgrading Data Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328Upgrading Data Environment with Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . 330

    Data Access Objects and Remote Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331Data Binding Upgrade Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331DAO/RDO in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332Replacing the Data Control with ADO Data Control in Visual Basic 6.0. . . . . . . . . . 332Replacing DAO/RDO with ADO in Visual Basic 6.0 . . . . . . . . . . . . . . . . . . . . . . . . 334Upgrading DAO / RDO without Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334Upgrading Data Access Objects (DAO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335Upgrading Remote Data Objects (RDO). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336

    Custom Data Access Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344Upgrading to a .NET Version of the Component . . . . . . . . . . . . . . . . . . . . . . . . . . 345Using COM Interop with Custom Data Access Components . . . . . . . . . . . . . . . . . . 346Upgrading Mixed Data Access Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346

    Converting Data Reports to Crystal Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

    Chapter 13Working with the Windows API 351

    Type Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352Changes to Integer and Long Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352Changes to Fixed-Length Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352

  • Contents ix

    Variable Type As Any Is No Longer Supported . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354Passing User-Defined Types to API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356Changes to AddressOf Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360Functions ObjPtr, StrPtr, and VarPtr Are No Longer Supported . . . . . . . . . . . . . . . . . . 363Moving API Calls to Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370

    Chapter 14Interop Between Visual Basic 6.0 and Visual Basic .NET 371

    Calling .NET Assemblies from Visual Basic 6.0 Clients . . . . . . . . . . . . . . . . . . . . . . . 372Calling Visual Basic 6.0 Libraries from Visual Basic .NET Clients . . . . . . . . . . . . . . . 372How to Achieve Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

    Access Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373Requirements for Interoperability with COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374Accessing .NET Assemblies Directly from Visual Basic 6.0 . . . . . . . . . . . . . . . . . . 375Creating Interoperability Wrappers in .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378Command Line Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380Data Type Marshaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381Error Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384Sinking COM Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390OLE Automation Call Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

    Resource Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395Constructors and Destructors in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . 395Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397

    Chapter 15Upgrading MTS and COM+ Applications 399

    Using MTS/COM+ in Visual Basic 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399Using COM+ in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400General Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403

    COM+ Application Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404Using SOAP Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404COM+ Application Proxies in .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406

    Upgrading MTS/COM+ Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407COM+ Example Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407COM+ Compensating Resource Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411COM+ Object Pooling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418COM+ Application Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419COM+ Shared Property Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421COM+ Object Constructor Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424COM+ Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427

  • Contentsx

    Additional COM+ Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432COM+ Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433Context Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436COM+ Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438

    The Event Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439The Event Publisher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439The Event Subscriber and Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440

    Message Queuing and Queued Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

    Chapter 16Application Completion 455

    Separating Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455No Assembly Separation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455Separation by Application Tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456Separation by Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456

    Upgrading Integrated Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456Integrating Help at Run Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458Integrating Help at Design Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459Upgrading WinHelp to HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462Integrating Context-Sensitive Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

    Run-time Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463Upgrading Application Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464

    Creating a New Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464Customizing Your Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467Merge Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471Web Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472COM+ Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476

    Chapter 17Introduction to Application Advancement 477

    Target Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478Advancing the Architecture, Design, and Implementation . . . . . . . . . . . . . . . . . . . . . . 478

    Advancing Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478Taking Advantage of Object-Oriented Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . 479Layering Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

  • Contents xi

    Chapter 18Advancements for Common Application Scenarios 497

    Windows Applications and Windows Forms Smart Clients . . . . . . . . . . . . . . . . . . . . . 497Business Components (Enterprise Services) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524

    Chapter 19Advancements for Common Web Scenarios 527

    Web Applications and ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527Architectural Advancements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530HTTP Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531

    Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532Web Services Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533Architecture Advancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533Creating a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536Consuming a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537Technology Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540

    Chapter 20Common Technology Scenarios 541

    Application Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541Using Identities and Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541Using Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545

    Application Manageability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548Using Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548Using Deployment and Update Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551Using Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552Using Tracing and Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552

    Application Performance and Scalability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552Exception Handling Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553String Handling Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553Database Access Considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553Multithreading and the BackgroundWorker Component . . . . . . . . . . . . . . . . . . . . . 554Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555

    Communication and State Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556Moving From DCOM to HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556Replacing Message Queuing with System.Messaging . . . . . . . . . . . . . . . . . . . . . . 558

    Upgrading ODBC and OLE DB Data Access Components . . . . . . . . . . . . . . . . . . . . . . 559The ODBC .NET Data Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560

  • Contentsxii

    The OLE DB .NET Data Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561Accessing Oracle Databases from the .NET Framework . . . . . . . . . . . . . . . . . . . . . 562

    Upgrading ADO to ADO.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562ADO.NET Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563ADO vs. ADO.NET Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567

    Chapter 21Testing Upgraded Applications 571

    Fitch & Mather Stocks 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572Test Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573Testing Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573

    Create Test Plan and Test Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574Create Test Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576Review the Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577Review of Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578Performing Unit Testing White Box Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580Black Box Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582White Box Testing Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585

    An Overview of Test Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586Test Strategy Based on the Waterfall Methodology . . . . . . . . . . . . . . . . . . . . . . . . 586Test Strategy Based on the Iterative Methodology. . . . . . . . . . . . . . . . . . . . . . . . . 589

    Test Strategy Based on the Agile Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591Tools for Testing Visual Basic .NET Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595

    NUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595FxCop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595Application Center Test (ACT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596Visual Studio Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596Trace and Debug Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596TraceContext Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597CLR Profiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597Enterprise Instrumentation Framework (EIF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599

    Appendix AReferences to Related Topics 601

    Visual Basic 6.0 Resource Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601Coding Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602Choosing File I/O Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602

  • Contents xiii

    Appendix BApplication Blocks, Frameworks, and Other Development Aids 603

    Using Visual Basic .NET Application Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603Building My Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605Building Visual Studio .NET Snippets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606Mobile Applications and the .NET Compact Framework . . . . . . . . . . . . . . . . . . . . . . . 607

    Microsoft Mobile Technology Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607Overview of the .NET Compact Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608Porting from eMbedded Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612Creating a Mobile Version of a Desktop Application . . . . . . . . . . . . . . . . . . . . . . . 614Synchronizing with Server Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619

    More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621

    Appendix C 623Introduction to Upgrading ASP 623

    Process Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625Preparing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626Upgrading the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626Testing and Debugging the Upgraded Application . . . . . . . . . . . . . . . . . . . . . . . . . 627

    Understanding the ASP to ASP.NET Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . 627Tasks Performed by the Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627Limitations of the Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628

    Preparing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629Preparing the Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629Preparing Your Code for the Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . 631

    Upgrading the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634Upgrade Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634Using the ASP to ASP.NET Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . 634Completing the Upgrade with Manual Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . 636

    Testing and Debugging the Upgraded Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 642Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644

    Appendix DUpgrading FMStocks 2000

    A Case Study 645About FMStocks 2000. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646

    Reasons FMStocks 2000 Is Used for the Case Study . . . . . . . . . . . . . . . . . . . . . . 646FMStocks 2000 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647FMStocks_AutomatedUpgrade Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647FMStocks_NET Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647

  • Contentsxiv

    FMStocks 2000 Assessment and Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647Overview of the Structure of FMStocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 648Overview of the Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649Obtaining the Upgrade Inventory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650Obtaining Source Code Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656Handling of Unsupported Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656Determining Application Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657

    Upgrading FMStocks 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660Planning the Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660Preparing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668Executing Automated Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668Applying Manual Upgrade Adjustments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670Functional Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678

    Index 679

  • Preface

    Microsoft Visual Basic development system is one of the most popular program-ming languages in use today. Its relative simplicity and power have helped shapemodern rapid application development, making it the language of choice for quicklyand efficiently building business applications.

    Like any widely used product, Visual Basic continues to be improved and adaptedas the world of computer technology changes. Visual Basic .NET marks the nextevolution of the language.

    Visual Basic has always been fairly easy to use and has provided techniques andtechnologies that were current at the time of each versions release. However, newtechnologies and techniques have come into use since Visual Basic 6.0 was released,and these are unavailable in this and earlier versions of the language. While object-based programming has been available in the language for years, true object-orientedfeatures have been unavailable. The ability to build distributed applications hasbeen severely limited. Other technologies such as Web services, mobile devices, and.NET have all become prominent in recent years. The need to support these andother features has prompted the release of a new version of Visual Basic.

    Visual Basic .NET marks a significant advance for the Visual Basic programminglanguage. As part of the Microsoft .NET Framework, it supports all the latest tech-nologies for building powerful and extensible business applications. Object-orientedprogramming techniques are now completely supported, making it possible toimplement full object-oriented designs. New forms features make it even easier tobuild rich desktop applications. Moreover, Web forms make it equally easy to createWeb applications.

    The changes made to Visual Basic .NET have made some features of earlier versionsobsolete. Although the new version does provide better ways to achieve the sameresult as these obsolete features, the changes break compatibility with earlier ver-sions of the language. This makes it impossible to automate the process of upgrad-ing applications created in earlier versions of Visual Basic to the latest version.Though it is possible to automate the process of upgrading applications created inearlier versions of the language to the latest version, entire applications cannot beupgraded through automation alone. Manual intervention will be required tocomplete the upgrade process.

    The purpose of this guide is to provide you with the information you need to up-grade an application from Visual Basic 6.0 to Visual Basic .NET. It describes the toolsand techniques that you need to upgrade your application and to start takingadvantage of many new features in Visual Basic .NET and the .NET Framework.

  • Prefacexvi

    Who Should Read This GuideThis guide is intended for software technical decision makers, solution architects,and software developers who are involved in Visual Basic 6.0 application or compo-nent development. It helps you understand the issues and risks that go along withupgrading to Visual Basic .NET. It also provides steps for preparing your applica-tions for a successful and cost-effective upgrade. Finally, it gives ideas and pointersabout how to advance your application after you successfully upgrade it to VisualBasic .NET.

    For Technical Decision MakersTechnical decision makers will find a wealth of information about analyzing andassessing the costs and benefits of upgrading Visual Basic 6.0 applications to VisualBasic .NET and how best to perform this upgrade using proven processes and tools.You will learn how to identify applications or parts of applications that may benefitmost from upgrading to .NET. You will also learn about the risks involved and theissues that should be carefully monitored during the upgrade process. Finally, youwill learn about Visual Basic. NET improvements that you can apply to your appli-cations after they are successfully upgraded.

    For Solution ArchitectsSolution architects will learn how best to plan and execute the upgrade project. Youwill learn how to effectively assess the complexity of the upgrade project and esti-mate the effort that is required to complete the upgrade. You will find informationabout how to identify the areas of your application that will need substantialmanual intervention to complete the upgrade. Furthermore, you will find a detaileddiscussion about the best practices for completing a successful upgrade project andhow this maps to tasks and milestones within your own project.

    For DevelopersDevelopers will find information about many Visual Basic 6.0 features and how theyare upgraded to Visual Basic .NET. A step-by-step process describes the most effec-tive strategies for completing a successful upgrade. A discussion of available toolsthat automate some of the process is provided. You will also find information aboutfeatures that are not automatically converted and suggestions for how best tomanually convert these features. Code samples are provided throughout the text toprovide practical examples of Visual Basic 6.0 code that is not automatically up-graded and examples of equivalent Visual Basic .NET code that you can use toreplace it. Finally, you will find ideas and pointers for improving your applicationsafter they are upgraded.

  • Preface xvii

    PrerequisitesAs mentioned earlier, this guide is intended for software developers, solutionarchitects, and technical decision makers who are considering or who have alreadydecided to upgrade Visual Basic 6.0 applications to Visual Basic .NET. For thisreason, this guide assumes that you have a certain degree of knowledge and experi-ence with Visual Basic 6.0. Also, you should be generally familiar with the .NETFramework, Visual Basic .NET in particular.

    This is not a how-to guide for Visual Basic 6.0, .NET application architecture, orVisual Basic .NET. The guide contains introductory explanations of many of thefeatures of Visual Basic 6.0, Visual Basic .NET, and the .NET Framework in general,but it provides these explanations only to create a context in which techniques forupgrading between these technologies can be more appropriately discussed. If youneed more information about these technologies, see the More Information sectionat the end of each chapter.

    How to Use This GuideMost chapters in this guide are independent and can be read in any order. However,it is recommended that you read in order Chapter 1, Introduction and Chapter 2,Practices for Successful Upgrades. These two chapters lay the important proce-dural groundwork for the upgrade process that serves as a foundation for the rest ofthe guide.

    Because this guide targets a diverse audience, from architectural specialists whooversee system design and integration to software developers who do the actualcoding, readers will undoubtedly get more value from some chapters than others.The list that follows summarizes the key points of each chapter to help you deter-mine which are more likely to focus on your particular areas of interest.

    This guide has been divided into the following four parts: Part 1, General Upgrade Practices, consists of Chapters 1 3, and focuses on

    the upgrade practices that are needed to make any upgrade project successful.Although the emphasis is on Visual Basic 6.0 to Visual Basic .NET upgrades,much of the information can be applied to any upgrade project. Part 1 includesthe following chapters: Chapter 1, Introduction, looks at the common reasons for upgrading to

    Visual Basic .NET and examines some of the strategies that you might con-sider to ensure a successful and cost effective upgrade.

    Chapter 2, Practices for Successful Upgrades, presents a proven methodol-ogy that covers each step of the upgrade process from planning and applica-tion preparation, through upgrading, and on to testing and quality assurancein .NET.

  • Prefacexviii

    Chapter 3, Assessment and Analysis, examines the first step of the upgradeprocess which focuses on assessing the scope and complexity of the plannedupgrade project.

    Part 2, Understanding the Upgrade Process, consisting of Chapters 4 6,provides a more technical overview of upgrading your code to Visual Basic .NET.Part 2 includes the following chapters: Chapter 4, Common Application Types, examines the different types of

    Visual Basic applications and presents suggestions for how to approach theupgrade of these applications, shortcuts that can be taken, and some of thedifficulties and issues that can arise and should be kept in mind.

    Chapter 5, The Visual Basic Upgrade Process, looks more closely at thepreparations and steps of performing an upgrade. The chapter includes thedetailed steps involved in using the Visual Basic Upgrade Wizard, which is anadd-in to the Microsoft Visual Studio .NET development system that per-forms much of the upgrade work for you. This chapter shows you how toprepare your application so that your use of the upgrade wizard is moreeffective and the amount of code that is automatically upgraded is maximized.

    Chapter 6, Understanding the Visual Basic Upgrade Wizard, describes indetail the capabilities and limitations of the Visual Basic Upgrade Wizard.

    Part 3, Manual Upgrade Tasks, consists of chapters 7 16, provides detailedinformation on those aspects of upgrading that cannot be performed automati-cally by the upgrade wizard and therefore require manual effort. Part 3 includesthe following chapters: Chapter 7, Upgrading Commonly-Used Visual Basic 6.0 Objects, catalogs

    many of the objects used in typical Visual Basic 6.0 applications that are notsupported in Visual Basic .NET. It gives techniques for upgrading these objectsmanually and suggestions for workarounds and alternatives to enable you tocomplete the upgrade successfully.

    Chapter 8, Upgrading Commonly-Used Visual Basic 6.0 Features, identifiesadditional Visual Basic 6.0 constructs that have changed or were omitted inVisual Basic .NET. The chapter provides information on the changes that havetaken place and on how to deal with them when you upgrade an application.

    Chapter 9, Upgrading Visual Basic 6.0 Forms Features, concentrates on thedifferences between Visual Basic 6.0 forms and the Windows Forms packagethat is used in Visual Basic .NET. It identifies upgrade problem areas associ-ated with forms and provides information on how to overcome them.

    Chapter 10, Upgrading Web Applications, provides information about howto upgrade Web-based Visual Basic 6.0 applications.

    Chapter 11, Upgrading String and File Operations, gives information thatdeals specifically with string and file manipulation. It covers the types of

  • Preface xix

    operations that are automatically upgraded when you apply the upgradewizard, as well as new operations that Visual Basic .NET offers.

    Chapter 12, Upgrading Data Access, addresses upgrading data access basedon Data Access Objects (DAO), Remote Data Objects (RDO), and ActiveX DataObjects (ADO). It shows techniques that you can use to accelerate the upgradeof database access code that is not handled by the upgrade wizard.

    Chapter 13, Working with the Windows API, discusses common issues thatarise when you upgrade Visual Basic 6.0 applications that use Windows APIfunction calls. It demonstrates how to replace common Windows API functioncalls with new methods that Visual Basic .NET provides.

    Chapter 14, Interop Between Visual Basic 6.0 and Visual Basic .NET, presentsoptions for interoperability between these two versions of the language. Itaddresses techniques to access Visual Basic 6.0 components from Visual Basic.NET assemblies and to access .NET assemblies from clients built in VisualBasic 6.0. It covers many issues that arise when you use Component ObjectModel (COM) to interoperate between these two languages and how COMworks in unmanaged and managed environments.

    Chapter 15, Upgrading MTS and COM+ Applications, discusses how toupgrade Microsoft Transaction Services (MTS) and COM+ components. It alsodescribes some of the deprecated functionality and how to deal with it whenyou upgrade an application.

    Chapter 16, Application Completion, covers some of the remaining areas ofyour application that are not core parts of your applications functionality, butare fundamental to having a finished product that provides the user with acomplete application. Topics include upgrading integrated help and productdeployment.

    Part 4, Beyond the Upgrade, consists of chapters 17 21 and covers what to doafter you complete the upgrade. Part 4 includes the following chapters: Chapter 17, Introduction to Application Advancement, looks at advance-

    ment options that you can use after the application has reached functionalequivalence in Visual Basic .NET. The information in this chapter includessuggestions for advancing the architecture, design, and implementation ofyour applications.

    Chapter 18, Advancements for Common Scenarios, suggests advancementsthat are based on specific application types, such as forms applications andenterprise services.

    Chapter 19, Advancements for Common Web Scenarios, is a continuation ofChapter 18 that focuses on advancements for Web-based applications.

  • Prefacexx

    Chapter 20, Common Technology Scenario Advancements, focuses onadvancements that apply to almost all types of applications. These advance-ments include enhancements to application security, manageability, perfor-mance and scalability, and communication and state management.

    Chapter 21, Testing Upgraded Applications, provides detailed informationabout strategies that you can use to verify the correctness and completeness ofyour application after it is upgraded and after you have implemented theadvancements that you want.

    Relevant Chapters for Technical Decision MakersTechnical decision makers will be most interested in information about assessmentand analysis, the risks and challenges of the upgrade, and application advancement.The following chapters contain this information: Chapter 1, Introduction Chapter 3, Assessment and Analysis Chapter 7, Upgrading Commonly-Used Visual Basic 6.0 Objects Chapter 8, Upgrading Commonly-Used Visual Basic 6.0 Language Features Chapter 9, Upgrading Visual Basic 6.0 Forms Features Chapter 10, Upgrading Web Applications Chapter 11, Upgrading String and File Operations Chapter 12, Upgrading Data Access Chapter 17, Introduction to Application Advancement Chapter 18, Advancements for Common Scenarios Chapter 19, Advancements for Common Web Scenarios Chapter 20, Common Technology Scenario Advancements

    Relevant Chapters for Solution ArchitectsSolution architects will be most interested in the information about the recom-mended upgrade process, assessment and analysis, best practices for managing anupgrade project, the risks associated with this process, and application advance-ment. The following chapters contain this information: Chapter 2, Practices for Successful Upgrades Chapter 3, Assessment and Analysis Chapter 4, Common Application Types Chapter 7, Upgrading Commonly-Used Visual Basic 6.0 Objects Chapter 8, Upgrading Commonly-Used Visual Basic 6.0 Language Features Chapter 9, Upgrading Visual Basic 6.0 Forms Features

  • Preface xxi

    Chapter 10, Upgrading Web Applications Chapter 11, Upgrading String and File Operations Chapter 12, Upgrading Data Access Chapter 13, Working with the Windows API Chapter 17, Introduction to Application Advancement Chapter 18, Advancements for Common Scenarios Chapter 19, Advancements for Common Web Scenarios Chapter 20, Common Technology Scenario Advancements

    Relevant Chapters for Software DevelopersSoftware developers will be most interested in the material that covers how thetechnical features of Visual Basic 6.0 map to Visual Basic .NET. This includes thefeatures that are converted automatically by existing tools and those that must bemanually upgraded. Furthermore, developers are likely to be interested in learninghow they can advance applications with features of the .NET Framework. Thefollowing chapters contain this information: Chapter 4, Common Application Types Chapter 5, The Visual Basic Upgrade Process Chapter 6, Understanding the Visual Basic Upgrade Wizard Chapter 7, Upgrading Commonly-Used Visual Basic 6.0 Objects Chapter 8, Upgrading Commonly-Used Visual Basic 6.0 Language Features Chapter 9, Upgrading Visual Basic 6.0 Forms Features Chapter 10, Upgrading Web Applications Chapter 11, Upgrading String and File Operations Chapter 12, Upgrading Data Access Chapter 13, Working with the Windows API Chapter 14, Interop Between Visual Basic 6.0 and Visual Basic .NET Chapter 17, Introduction to Application Advancement Chapter 18, Advancements for Common Scenarios Chapter 19, Advancements for Common Web Scenarios Chapter 20, Common Technology Scenario Advancements

    Document ConventionsThis guide uses the style conventions and terminology shown in Table 1 on thenext page.

  • Prefacexxii

    Table 1: Document Conventions

    Element Meaning

    bold font Characters that you type exactly as shown, including commands andswitches appear in bold font. Programming elements, such as methods,functions, data types, and data structures appear in bold font (exceptwhen part of a code sample, in which case they appear in monospacefont). User interface elements are also bold.

    Italic font Variables for which you supply a specific value. For example,Filename.ext could refer to any valid file name for the case in question.New terminology also appears in italic on first use.

    Monospace font Code samples.

    %SystemRoot% The folder in which the Windows operating system is installed.

    Feedback and SupportEvery effort has been made to ensure the accuracy of the content of this guide. Allsample code and procedures have been independently tested. Also, all referencesand descriptions of tools, specifications, and standards have been checked and arebelieved to be accurate at the time this guide is published.

    If you have any comments or suggestions, or if you find any inaccuracies, pleasesend them by e-mail to [email protected].

    Note: There is a community site for this guide on GotDotNet. This site contains a Downloadssection where you can obtain the Visual Basic 6.0 Upgrade Assessment Tool that is describedin this guide. It also contains forums where you can post feedback, ask questions, or providesuggestions.

    Principal AuthorsThe content for this guide and the accompanying Visual Basic 6.0 Upgrade Assess-ment Tool were developed by the following individuals at ArtinSoft: Project Lead: Federico Zoufaly Guidance: Csar Muoz , Paul Dermody, Manfred Dahmen, Ronny Vargas,

    Hendel Valverde, Jos David Araya, Oscar Calvo, Allan Cantillo, Alvaro Rivera,Christian Saboro, Juan Fernando Pea, Xavier Morera, Ivn Sanabria

    Assessment tool development: Rolando Mndez

    http://www.gotdotnet.com/codegallery/codegallery.aspx?id=07c69750-9b49-4783-b0fc-94710433a66dhttp://www.artinsoft.com
  • Preface xxiii

    ContributorsThe Visual Basic 6.0 Upgrade Assessment Tool and the Upgrading Visual Basic 6.0 toVisual Basic .NET and Visual Basic 2005 guide were produced with the help of thefollowing people. Program Manager: William Loeffler (Microsoft Corporation) Product Manager: Eugenio Pace (Microsoft Corporation) Architect: Keith Pleas (Guided Design) Test: Edward Lafferty (Microsoft Corporation); Ashish Babbar, Terrence Cyril J.,

    Manish Duggal, Chaitanya Bijwe, Arumugam Subramaniyam, UmashankarMurugesan, Dhanaraj Subbian, Tarin R. Shah, Dipika Khanna, Gayatri Patil, andSandesh Pandurang Ambekar (Infosys Technologies Ltd)

    Documentation and Samples: RoAnn Corbisier (Microsoft Corporation); TinaBurden McGrayne and Melissa Seymour (TinaTech Inc.); Sharon Smith (LindaWerner & Associates Inc.); Francisco Fernandez and Paul Henry (Wadeware LLC)

    AcknowledgementsMany thanks to the following individuals who provided invaluable assistanceduring the development of this guide: Dan Appleman (Desaware Inc.) Joe Binder (Microsoft Corporation) Rob Copeland (Microsoft Corporation) Jackie Goldstein (Renaissance Computer Systems Ltd.) Ed Hickey (Microsoft Corporation) Billy Hollis Edward Jezierski (Microsoft Corporation) Chris Kinsman (Vergent Software) Deborah Kurata (InStep Technologies) Julia Lerman (The Data Farm) Rockford Lhotka (Magenic Technologies) Christian Nielsen (Volvo Information Technology AB) Jay Roxe (Microsoft Corporation) Jay Schmelzer (Microsoft Corporation) Scott Swigart (Swigart Consulting) The Visual Basic MVPs (Microsoft Valued Professionals)

  • Prefacexxiv

    More InformationFor more information about the Visual Basic 6.0 Upgrade Assessment Tool and todownload it, see Visual Basic 6 to Visual Basic .NET Migration Guide onGotDotNet:http://www.gotdotnet.com/codegallery/codegallery.aspx?id=07c69750-9b49-4783-b0fc-94710433a66d.

    For more information about ArtinSoft, see the ArtinSoft Web site:http://www.artinsoft.com.

    http://www.gotdotnet.com/codegallery/codegallery.aspx?id=07c69750-9b49-4783-b0fc-94710433a66dhttp://www.gotdotnet.com/codegallery/codegallery.aspx?id=07c69750-9b49-4783-b0fc-94710433a66dhttp://www.artinsoft.com
  • 1Introduction

    Before investing time, money, and energy into an upgrade project, it is importantto understand why an upgrade is beneficial. It is equally important to understandpotential upgrade strategies to minimize costs and risks. This chapter presents thebenefits of upgrading Visual Basic 6.0 applications to Visual Basic .NET, and pro-vides several strategies that you can apply to successfully upgrade your application.

    Why Consider an Upgrade Project?Before deciding to upgrade an application from Visual Basic 6.0 to Visual Basic .NET,it is helpful to understand why you should consider upgrading at all. This sectiondiscusses why and when it makes sense to upgrade your application.

    Usually, you have business requirements that compel you to upgrade an applicationfrom Visual Basic 6.0 to Visual Basic .NET. Common reasons, or drivers, to upgradean application to Visual Basic .NET are: To Web-enable the application, or enhance an existing Web-enabled application

    with ASP.NET features, such as tracing, flexible state management, scaleable dataaccess, and improved performance.

    To take advantage of the improvements in developer productivity and the en-hanced development features that Visual Basic .NET, the .NET Framework, andVisual Studio .NET provide particularly if new functionality is required thatis more easily implemented in Visual Basic .NET, such as Web services.

    To consolidate your companys software assets. For example, if your new applica-tions are built in Visual Basic .NET, there is often a need to upgrade other applica-tions built with earlier versions of Visual Basic. This improves system integrationand reduces the overhead of needing experts on different platforms.

  • Upgrading Visual Basic 6.0 Applications2

    To reduce the cost of ongoing business activity. For example, the increasedscalability and performance of applications that are upgraded to Visual Basic.NET, and the increased productivity of developers, can reduce the costs ofregular business activity.

    To improve the maintenance of an application in any of these situations: Your business does not have an in-house expert on the application. Your business has a high turnover of staff. Your business does not have enough resources to support the application. The available documentation is limited or outdated.

    Of course, a combination of these drivers may influence your decision to upgrade.These drivers can be seen as a kind of spectrum, going from push factors (factors thatcompel you to upgrade the Visual Basic application to fit a new environment) to pullfactors (factors that result from the business wanting to seize an opportunity togrow, reach new customers, or add products and services).

    Minimum Information Needed to Make a DecisionTo determine whether upgrading your application is appropriate, you shouldperform a project feasibility analysis. The first step of your project feasibility analy-sis is to collect information about the current status of your Visual Basic 6.0 applica-tions. To make the best possible decision about whether to upgrade the applicationto Visual Basic .NET, your analysis should address the following information. Project goals and priorities. Be sure to have clearly documented project goals,

    with a list of priorities for each goal. Make a point to clarify how an upgrade willmeet these goals. Some questions that you want answered before making anupgrade decision are the following: What is the expected life of the application? Is this a temporary solution or

    something more long term? An application with a short expected lifetimebecause of changing business needs or processes is unlikely to be worthupgrading. However, an application whose functionality remains core to thebusiness and will remain so for a period that is sufficiently longer than thelength of the upgrade project is a good candidate for upgrading.

    When is the upgraded application needed for a production environment? Ifthe upgrade project will take longer than the schedule allows, it may be moreappropriate to replace the application.

    Do you have realistic expectations for improvements in performance, security,scalability, and other potential benefits? Do you also understand that addi-tional modifications may be required to achieve these improvements? It isimportant to realize that the upgrade process alone may not improve theperformance or scalability of your application. Improvements like these often

  • Chapter 1: Introduction 3

    occur during application advancement, which is discussed in Chapter 20,Common Technology Scenario Advancements.

    How many users will this application support in its lifetime? Do you clearlyunderstand how Visual Basic .NET will help meet increased user demand?Changes to applications with a large user base will have a significant impacton those users. However, the impact may be a positive one if the changes arefor the better. Improved performance features and modern technologiesavailable in Visual Basic .NET may improve the application experience for theuser.

    Do you plan to add new features to the application, such as integration withother systems or access from the Web? Again, these improvements are part ofapplication advancement and require effort beyond upgrading the application.

    Business value of the applications. Is the functionality that is provided by thisapplication unique, or are there third-party applications that can be used to dothe same job? Be sure that you can demonstrate the specialized nature of theapplication you propose to upgrade.A related question is whether the application is a reasonable fit to your businessneeds. You need to demonstrate that the application does provide a function thatfits the needs of your business. If the application has been around for a long time,you need to make sure that the functionality of the application is not outdated,and that it still closely fits the processes and operations required by your busi-ness.

    Development environment. Moving to Visual Basic .NET also means updatingyour development environment. Your developers will have to learn a new inte-grated development environment (IDE), and a new language. You will also haveto purchase software licenses for the tools you need to perform the upgrade andto maintain the upgraded code.

    Developer skills. Do your developers have knowledge or experience with the.NET Framework in general and with Visual Basic .NET specifically? Althoughupgrading an application is a good way to learn a new language, you shouldensure that your developers have basic knowledge of the .NET Framework andVisual Basic .NET before beginning the upgrade project.

    Quality assurance environment. It is likely that the upgrade project will affectyour quality assurance procedures, especially if they are automated. Make surethat you also consider any effort that will be required to upgrade your testingenvironments.

    Application architecture and complexity. Most applications for large enterpriseshave multiple dependencies on other systems within the company, as well as onsystems and libraries from third-party vendors. Make sure you understand thenature of these dependencies and consider any changes that the systems requirebefore they will work with the upgraded application.

  • Upgrading Visual Basic 6.0 Applications4

    Also, consider the effects that an upgraded application will have on other appli-cations that depend on it. How will they be affected by the move to Visual Basic.NET?Finally, is the application of good quality? Good quality indicates both its qualityas a business tool and the quality of the source code that implements it. This is anassessment of the effective value of the application from the view of the user andthe developer. The user requires an application that is stable, that does the jobwell, and that is easy to use. A developer requires an application with code that isunderstandable, well-documented, and not unnecessarily complex.

    Making the following three assessments will help you gather the information thatyou need to make a decision about upgrading your application. They will also helpyou accurately estimate the effort that is needed to select and complete the appropri-ate upgrade process: Business value assessment Code quality assessment Development environment assessment

    Business Value AssessmentWhen you are considering investing time and money into an upgrade project, it isimportant to evaluate the importance of the existing applications functionality toyour business. Is there opportunity for return on investment if you do upgrade theapplication? This can be shown by determining how much has been invested in theapplication so far. Also, you might highlight unique features of the application thatcannot be replaced by a third-party off-the-shelf product. Answering these questionswill help you determine the value of the application to your business: Are the applications basic inputs and outputs based on legacy file formats?

    Applications with inputs and outputs based on legacy file formats that are noteasily translatable may be problematic to upgrade. On the other hand, moving anapplication to Visual Basic .NET and upgrading data to a more general format,such as XML, may leverage your application for future enhancements or changesin technology.

    What kind of data does the application process, and are there other applicationsthat can do the same job? Applications that are responsible for processing impor-tant business data are highly valuable to your business. If there are no otherapplications, such as third-party off-the-shelf products, available to process thisdata, ensuring the lifespan of your application by upgrading it to Visual Basic.NET may be a logical step.

    How does this application interact with its users, whether they are human orcomputer-based clients? Providing a clean, friendly interface for human usersincreases the value of an application. New or improved user interface features of

  • Chapter 1: Introduction 5

    a new language version, such as Visual Basic .NET, may increase user apprecia-tion. Similarly, an application that coordinates with other applications must haveclean data transmission. It should use dependable data formats and communica-tion protocols. Newer languages often support improved transmission protocolsor data formats that make inter-application communication simpler and morereliable.

    What other systems depend on your application, and are there third-party prod-ucts that could provide the same data or function? If other systems are dependenton your application, and there are not any third-party products to replace yourapplication, the value of your application is high. Ensuring the future of theapplication becomes more important in this situation.

    What business rules are inherent to your application that are difficult to repro-duce elsewhere? An application with a large number of business rules that areunavailable in other applications is very valuable to a company.

    What role does this application play in current business processes in your com-pany? What would happen to those processes if the application was removed?An application that automates a small number of mundane tasks is not likely tobe very valuable. In contrast, an application that processes large amounts ofbusiness data will be highly valuable. Even applications designed to assistemployees by automating a large number of data-oriented tasks can be valuable,if such an application improves user efficiency.

    Another driver for upgrading an application is reducing the total cost of ownership(TCO). The .NET Framework provides many features that increase developer pro-ductivity, while also lowering deployment and maintenance costs to decrease TCO.

    Code Quality AssessmentAn important factor in determining whether to upgrade your application is thecurrent quality of its code design and implementation. Detailed analysis of yourapplications source code will provide information on code quality, design complex-ity, and component dependencies. You can use the Visual Basic Upgrade AssessmentTool to help capture some of this information. For a complete description of the tool,see Chapter 3, Assessment and Analysis. The Visual Basic Upgrade AssessmentTool is provided with this guide on the companion CD or you can download it fromthe GotDotNet community site.

    The assessment tool was created to help you estimate the effort that is required toupgrade an application, but it can also help you understand the structural complex-ity of the application and its design quality. For this discussion, design qualityindicates the suitability of the code implementation given the functionality that isrequired by the application. For example, applications that have gone throughmultiple iterations over several years with different programmers often containexcessive redundant dependencies and unused code. This indicates poor designquality.

    http://www.gotdotnet.com/codegallery/codegallery.aspx?id=07c69750-9b49-4783-b0fc-94710433a66d
  • Upgrading Visual Basic 6.0 Applications6

    The assessment tool collects the following metrics: Size metrics. These include metrics such as the number of lines of code, forms,

    designers, modules, classes, components, user controls, and data sources. Usage metrics. These include functions, types, and properties. Complexity metrics. The assessment tool recognizes the same things that cause

    the upgrade wizard to generate errors, warnings, and issues (EWIs). These EWIsimply specific modifications that are required to resolve them. The assessmenttool assigns complexities to these EWIs. This helps you estimate the work thatneeds to be performed to remedy all of the reported issues.

    Dependency diagrams. The assessment tool generates the call graphs for eachfunction and the resulting dependencies between modules and files. In addition,the tool lists missing libraries and files. Use this information to determine pos-sible upgrade roadmaps that is, the order in which modules should be up-graded.

    There are many types of applications and different technologies that can be used tobuild them. If you are considering upgrading your applications with the Visual BasicUpgrade Wizard, you should be aware of some of the tools limitations. The follow-ing types of applications are a sample of the those with features that are only par-tially supported, or are not supported at all, by the upgrade wizard and some thatare not supported at all by Visual Basic .NET: A complex distributed application with several different layers of objects that

    communicate through COM. A Visual Basic 5.0 or earlier application that has not made the transition to Visual

    Basic 6.0. An Internet project that uses Microsoft ActiveX technologies, Web classes, or

    DHTML. None of these development technologies is supported in Visual Basic.NET.

    A database project that is based on the Data Environment Designer, which is alsonot supported in Visual Basic .NET.

    A database project that uses data binding to bind data sources to controls. An ActiveX control or ActiveX DLL project. A database client application with user controls.

    Although these features and applications are not directly supported in Visual Basic.NET, there is always an alternative (and often better) way to achieve the samefunctionality within Visual Basic .NET. A more complete list of features that are notautomatically upgraded by the upgrade wizard is given in Chapters 7 through 11.

    If your applications fit into any of these scenarios, your project plan should allowtime to identify and analyze upgrade alternatives for the technologies involved. Youshould also allocate time to review, re-design, and realize your target architecture.

  • Chapter 1: Introduction 7

    Code quality is also affected by the status of the development work on the originalapplication. If any development initiatives are currently in progress, the code will beless stable. The code may contain bugs, incomplete features, or even invalid codethat will not compile.

    The best time to upgrade is when the application code base is stable but is due forenhancements. This strategy gives you the opportunity to combine the upgradeeffort with feature enhancements. In contrast, it is best to avoid upgrading yourapplications when undergoing a period of intense change, unless you have a verystrongly controlled code management process. Upgrading a large application maytake several weeks or even months. During this time, changes made to the originalcode base will also be required in the upgraded code base. The process of maintain-ing two code bases that are each undergoing changes is prone to error and is likelyto result in a disparity between the two versions of the application. If you decidethat it is necessary to make changes to the original applications while you alsoupgrade them, it is recommended that you minimize disruption by choosing mod-ules to upgrade that are stable and that progressively cover all of your application.

    Code quality can affect the decision to upgrade in many ways. A stable applicationwith a well designed, implemented, tested, and documented code base that hasdrifted away from the business needs (either through revisions in the application orchanges to the busines