WillyDev VB6aNET
WillyDev VB6aNET
0
Applications to Visual Basic .NET
and Visual Basic 2005
Upgrading Visual Basic 6.0
Applications to Visual Basic .NET
and Visual Basic 2005
p a t t er ns & p ra c t i c es
ISBN 0-7356-2298-1
Information in this document, including URL and other Internet Web site
references, is subject to change without notice. Unless otherwise noted, the
example companies, organizations, products, domain names, e-mail addresses,
logos, people, places, and events depicted herein are fictitious, and no association
with any real company, organization, product, domain name, e-mail address, logo,
person, place, or event is intended or should be inferred. Complying with all
applicable copyright laws is the responsibility of the user. Without limiting the
rights under copyright, no part of this document may be reproduced, stored in or
introduced into a retrieval system, or transmitted in any form or by any means
(electronic, mechanical, photocopying, recording, or otherwise), or for any
purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other
intellectual property rights covering subject matter in this document. Except as
expressly provided in any written license agreement from Microsoft, the furnishing
of 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 or
trademarks of Microsoft Corporation in the United States and/or other countries.
ArtinSoft is the registered trademark of ArtinSoft Corporation in the United States
and/or other countries.
The names of actual companies and products mentioned herein may be the
trademarks of their respective owners.
Contents
Preface xv
Who Should Read This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
For Technical Decision Makers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
For Solution Architects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
For Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
How to Use This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Relevant Chapters for Technical Decision Makers . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Relevant Chapters for Solution Architects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Relevant Chapters for Software Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Document Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Feedback and Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Principal Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv
Chapter 1
Introduction 1
Why Consider an Upgrade Project? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Minimum Information Needed to Make a Decision . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Upgrade Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Moving from Visual Basic 6.0 to Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Increased Productivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Better Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Application Extendibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Improved Reliability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Improved Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Improved Deployment Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Increased Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Benefits of the Visual Basic 6.0 to Visual Basic .NET Upgrade Wizard . . . . . . . . . . . 23
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Chapter 2
Practices for Successful Upgrades 25
Functional Equivalence and Application Advancement . . . . . . . . . . . . . . . . . . . . . . . . . 25
Functional Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Application Advancement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
iv Contents
Chapter 3
Assessment and Analysis 69
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Project Scope and Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Evaluating Upgrade Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Business Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Technical Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Gathering Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Assessing Application Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Application Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Contents v
Application Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Using the Assessment Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Current and Target Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Inventory to Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Source Code Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Handling Unsupported Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Application Dependences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Missing Application Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Estimating Effort and Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Methodology Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Aspects to Be Estimated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Understanding the Effort – Total Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Understanding the Configuration Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Chapter 4
Common Application Types 107
Identifying and Upgrading Application Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Determining Application Type and Functional Equivalency . . . . . . . . . . . . . . . . . . . 108
Determining Component and Project Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Desktop and Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Architecture Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Desktop Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Application Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Native DLLs and Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Interoperability Between .NET and COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Reusable Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
ActiveX Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
ActiveX Controls Embedded in Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
ActiveX Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Distributed Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
DCOM Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
MTS and COM+ Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Chapter 5
The Visual Basic Upgrade Process 139
Procedure Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Application Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Development Environment Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Upgrade Wizard Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Removing Unused Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
vi Contents
Chapter 6
Understanding the Visual Basic Upgrade Wizard 183
Using the Upgrade Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Tasks Performed by the Upgrade Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Code Modification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Reference Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
The Upgrade Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Supported Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Visual Basic 6.0 Language Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Visual Basic 6.0 Native Libraries (VB, VBA, VBRUN) . . . . . . . . . . . . . . . . . . . . . . . 203
Visual Basic 6.0 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
ActiveX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Chapter 7
Upgrading Commonly-Used Visual Basic 6.0 Objects 217
Upgrading the App Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Upgrading the Screen Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Upgrading the Printer Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Upgrading the Printers Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Upgrading the Forms Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Upgrading the Clipboard Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Upgrading the Licenses Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Upgrading the Controls Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Contents vii
Chapter 8
Upgrading Commonly-Used Visual Basic 6.0 Language Features 247
Resolving Issues with Default Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Resolving Issues with Custom Collection Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Dealing with Changes to Commonly-Used Functions and Objects . . . . . . . . . . . . . . . . 253
Dealing with Changes to TypeOf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Upgrading References to Visual Basic 6.0 Enum Values . . . . . . . . . . . . . . . . . . . . . . 258
Defining Your Own Constant Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Using the Non-Constant Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Dealing with Changes to Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Legacy Visual Basic Language Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Upgrading Add-ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Chapter 9
Upgrading Visual Basic 6.0 Forms Features 275
Handling Changes to Graphics Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Removal of the Line Control in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . 275
Removal of the Shape Control in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . 276
Handling Changes to the PopupMenu Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Handling Changes to the ClipControls Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Drag-and-Drop Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Drag-and-Drop Functionality in Visual Basic 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Drag-and-Drop Functionality in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . 282
Handling Changes to the MousePointer and MouseIcon Properties . . . . . . . . . . . . . . 286
Handling Changes to Property Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
Handling Changes to the OLE Container Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Handling Changes to Control Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Accessing Control Arrays as a Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Adding Controls Dynamically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Handling Changes to DDE Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Chapter 10
Upgrading Web Applications 301
Upgrading ActiveX Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Upgrading Web Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
viii Contents
Chapter 11
Upgrading String and File Operations 307
Operations Handled by the Upgrade Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Auto-Upgraded String Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
Auto-Upgraded File Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Manual String and File Operation Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Replacing Strings with StringBuilders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Replacing Complex String Manipulation with Regular Expressions . . . . . . . . . . . . . 314
Improving File I/O with Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
File Access Through the File System Object Model . . . . . . . . . . . . . . . . . . . . . . . . 319
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Chapter 12
Upgrading Data Access 323
General Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
ActiveX Data Objects (ADO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Upgrading ADO Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Projects without ADO Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Upgrading Data Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Upgrading Data Environment with Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Data Access Objects and Remote Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Data Binding Upgrade Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
DAO/RDO in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Replacing the Data Control with ADO Data Control in Visual Basic 6.0 . . . . . . . . . . 332
Replacing DAO/RDO with ADO in Visual Basic 6.0 . . . . . . . . . . . . . . . . . . . . . . . . 334
Upgrading DAO / RDO without Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Upgrading Data Access Objects (DAO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Upgrading Remote Data Objects (RDO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Custom Data Access Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
Upgrading to a .NET Version of the Component . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Using COM Interop with Custom Data Access Components . . . . . . . . . . . . . . . . . . 346
Upgrading Mixed Data Access Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Converting Data Reports to Crystal Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Chapter 13
Working with the Windows API 351
Type Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Changes to Integer and Long Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Changes to Fixed-Length Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Contents ix
Chapter 14
Interop Between Visual Basic 6.0 and Visual Basic .NET 371
Calling .NET Assemblies from Visual Basic 6.0 Clients . . . . . . . . . . . . . . . . . . . . . . . 372
Calling Visual Basic 6.0 Libraries from Visual Basic .NET Clients . . . . . . . . . . . . . . . 372
How to Achieve Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Access Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
Requirements for Interoperability with COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Accessing .NET Assemblies Directly from Visual Basic 6.0 . . . . . . . . . . . . . . . . . . 375
Creating Interoperability Wrappers in .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Command Line Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
Data Type Marshaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Error Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Sinking COM Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
OLE Automation Call Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Resource Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Constructors and Destructors in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . 395
Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Chapter 15
Upgrading MTS and COM+ Applications 399
Using MTS/COM+ in Visual Basic 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Using COM+ in Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
General Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
COM+ Application Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
Using SOAP Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
COM+ Application Proxies in .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Upgrading MTS/COM+ Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
COM+ Example Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
COM+ Compensating Resource Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
COM+ Object Pooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
COM+ Application Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
COM+ Shared Property Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
COM+ Object Constructor Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
COM+ Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
x Contents
Chapter 16
Application Completion 455
Separating Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
No Assembly Separation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Separation by Application Tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
Separation by Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
Upgrading Integrated Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
Integrating Help at Run Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
Integrating Help at Design Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Upgrading WinHelp to HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
Integrating Context-Sensitive Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Run-time Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Upgrading Application Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Creating a New Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Customizing Your Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Merge Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Web Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
COM+ Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
Chapter 17
Introduction to Application Advancement 477
Target Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Advancing the Architecture, Design, and Implementation . . . . . . . . . . . . . . . . . . . . . . 478
Advancing Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Taking Advantage of Object-Oriented Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Layering Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
Contents xi
Chapter 18
Advancements for Common Application Scenarios 497
Windows Applications and Windows Forms Smart Clients . . . . . . . . . . . . . . . . . . . . . 497
Business Components (Enterprise Services) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Chapter 19
Advancements for Common Web Scenarios 527
Web Applications and ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
Architectural Advancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
HTTP Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
Web Services Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Architecture Advancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Creating a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
Consuming a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Technology Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Chapter 20
Common Technology Scenarios 541
Application Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
Using Identities and Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
Using Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
Application Manageability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Using Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Using Deployment and Update Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
Using Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Using Tracing and Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Application Performance and Scalability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Exception Handling Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
String Handling Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
Database Access Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
Multithreading and the BackgroundWorker Component . . . . . . . . . . . . . . . . . . . . . 554
Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
Communication and State Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Moving From DCOM to HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Replacing Message Queuing with System.Messaging . . . . . . . . . . . . . . . . . . . . . . 558
Upgrading ODBC and OLE DB Data Access Components . . . . . . . . . . . . . . . . . . . . . . 559
The ODBC .NET Data Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
xii Contents
Chapter 21
Testing Upgraded Applications 571
Fitch & Mather Stocks 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Test Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
Testing Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
Create Test Plan and Test Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
Create Test Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576
Review the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
Review of Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Performing Unit Testing – White Box Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
Black Box Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
White Box Testing – Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
An Overview of Test Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
Test Strategy Based on the Waterfall Methodology . . . . . . . . . . . . . . . . . . . . . . . . 586
Test Strategy Based on the Iterative Methodology . . . . . . . . . . . . . . . . . . . . . . . . . 589
Test Strategy Based on the Agile Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Tools for Testing Visual Basic .NET Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
NUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
FxCop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
Application Center Test (ACT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
Visual Studio Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
Trace and Debug Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
TraceContext Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
CLR Profiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Enterprise Instrumentation Framework (EIF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
Appendix A
References to Related Topics 601
Visual Basic 6.0 Resource Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Coding Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
Choosing File I/O Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
Contents xiii
Appendix B
Application Blocks, Frameworks, and Other Development Aids 603
Using Visual Basic .NET Application Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Building “My” Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
Building Visual Studio .NET Snippets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606
Mobile Applications and the .NET Compact Framework . . . . . . . . . . . . . . . . . . . . . . . 607
Microsoft Mobile Technology Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
Overview of the .NET Compact Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
Porting from eMbedded Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612
Creating a Mobile Version of a Desktop Application . . . . . . . . . . . . . . . . . . . . . . . 614
Synchronizing with Server Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621
Appendix C 623
Introduction to Upgrading ASP 623
Process Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
Preparing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626
Upgrading the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626
Testing and Debugging the Upgraded Application . . . . . . . . . . . . . . . . . . . . . . . . . 627
Understanding the ASP to ASP.NET Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . 627
Tasks Performed by the Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
Limitations of the Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
Preparing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
Preparing the Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
Preparing Your Code for the Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . 631
Upgrading the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
Upgrade Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
Using the ASP to ASP.NET Migration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
Completing the Upgrade with Manual Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
Testing and Debugging the Upgraded Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 642
Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
Appendix D
Upgrading FMStocks 2000 —
A Case Study 645
About FMStocks 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
Reasons FMStocks 2000 Is Used for the Case Study . . . . . . . . . . . . . . . . . . . . . . 646
FMStocks 2000 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
FMStocks_AutomatedUpgrade Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
FMStocks_NET Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
xiv Contents
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 shape
modern rapid application development, making it the language of choice for quickly
and efficiently building business applications.
Like any widely used product, Visual Basic continues to be improved and adapted
as the world of computer technology changes. Visual Basic .NET marks the next
evolution of the language.
Visual Basic has always been fairly easy to use and has provided techniques and
technologies that were current at the time of each version’s release. However, new
technologies 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-oriented
features have been unavailable. The ability to build distributed applications has
been severely limited. Other technologies such as Web services, mobile devices, and
.NET have all become prominent in recent years. The need to support these and
other features has prompted the release of a new version of Visual Basic.
Visual Basic .NET marks a significant advance for the Visual Basic programming
language. As part of the Microsoft .NET Framework, it supports all the latest tech-
nologies for building powerful and extensible business applications. Object-oriented
programming techniques are now completely supported, making it possible to
implement full object-oriented designs. New forms features make it even easier to
build rich desktop applications. Moreover, Web forms make it equally easy to create
Web applications.
The changes made to Visual Basic .NET have made some features of earlier versions
obsolete. Although the new version does provide better ways to achieve the same
result 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 in
earlier versions of the language to the latest version, entire applications cannot be
upgraded through automation alone. Manual intervention will be required to
complete 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 tools
and techniques that you need to upgrade your application and to start taking
advantage of many new features in Visual Basic .NET and the .NET Framework.
xvi Preface
For Developers
Developers will find information about many Visual Basic 6.0 features and how they
are 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 tools
that automate some of the process is provided. You will also find information about
features that are not automatically converted and suggestions for how best to
manually convert these features. Code samples are provided throughout the text to
provide 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 to
replace it. Finally, you will find ideas and pointers for improving your applications
after they are upgraded.
Preface xvii
Prerequisites
As mentioned earlier, this guide is intended for software developers, solution
architects, and technical decision makers who are considering or who have already
decided to upgrade Visual Basic 6.0 applications to Visual Basic .NET. For this
reason, 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 .NET
Framework, Visual Basic .NET in particular.
This is not a how-to guide for Visual Basic 6.0, .NET application architecture, or
Visual Basic .NET. The guide contains introductory explanations of many of the
features 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 for
upgrading between these technologies can be more appropriately discussed. If you
need more information about these technologies, see the “More Information” section
at the end of each chapter.
● Chapter 3, “Assessment and Analysis,” examines the first step of the upgrade
process which focuses on assessing the scope and complexity of the planned
upgrade 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 the
upgrade of these applications, shortcuts that can be taken, and some of the
difficulties and issues that can arise and should be kept in mind.
● Chapter 5, “The Visual Basic Upgrade Process,” looks more closely at the
preparations and steps of performing an upgrade. The chapter includes the
detailed steps involved in using the Visual Basic Upgrade Wizard, which is an
add-in to the Microsoft Visual Studio® .NET development system that per-
forms much of the upgrade work for you. This chapter shows you how to
prepare your application so that your use of the upgrade wizard is more
effective and the amount of code that is automatically upgraded is maximized.
● Chapter 6, “Understanding the Visual Basic Upgrade Wizard,” describes in
detail the capabilities and limitations of the Visual Basic Upgrade Wizard.
● Part 3, “Manual Upgrade Tasks,” consists of chapters 7 – 16, provides detailed
information on those aspects of upgrading that cannot be performed automati-
cally by the upgrade wizard and therefore require manual effort. Part 3 includes
the 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 not
supported in Visual Basic .NET. It gives techniques for upgrading these objects
manually and suggestions for workarounds and alternatives to enable you to
complete the upgrade successfully.
● Chapter 8, “Upgrading Commonly-Used Visual Basic 6.0 Features,” identifies
additional Visual Basic 6.0 constructs that have changed or were omitted in
Visual Basic .NET. The chapter provides information on the changes that have
taken place and on how to deal with them when you upgrade an application.
● Chapter 9, “Upgrading Visual Basic 6.0 Forms Features,” concentrates on the
differences between Visual Basic 6.0 forms and the Windows Forms package
that 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 how
to upgrade Web-based Visual Basic 6.0 applications.
● Chapter 11, “Upgrading String and File Operations,” gives information that
deals specifically with string and file manipulation. It covers the types of
Preface xix
operations that are automatically upgraded when you apply the upgrade
wizard, as well as new operations that Visual Basic .NET offers.
● Chapter 12, “Upgrading Data Access,” addresses upgrading data access based
on Data Access Objects (DAO), Remote Data Objects (RDO), and ActiveX Data
Objects (ADO). It shows techniques that you can use to accelerate the upgrade
of database access code that is not handled by the upgrade wizard.
● Chapter 13, “Working with the Windows API,” discusses common issues that
arise when you upgrade Visual Basic 6.0 applications that use Windows API
function calls. It demonstrates how to replace common Windows API function
calls with new methods that Visual Basic .NET provides.
● Chapter 14, “Interop Between Visual Basic 6.0 and Visual Basic .NET,” presents
options for interoperability between these two versions of the language. It
addresses techniques to access Visual Basic 6.0 components from Visual Basic
.NET assemblies and to access .NET assemblies from clients built in Visual
Basic 6.0. It covers many issues that arise when you use Component Object
Model (COM) to interoperate between these two languages and how COM
works in unmanaged and managed environments.
● Chapter 15, “Upgrading MTS and COM+ Applications,” discusses how to
upgrade Microsoft Transaction Services (MTS) and COM+ components. It also
describes some of the deprecated functionality and how to deal with it when
you upgrade an application.
● Chapter 16, “Application Completion,” covers some of the remaining areas of
your application that are not core parts of your application’s functionality, but
are fundamental to having a finished product that provides the user with a
complete application. Topics include upgrading integrated help and product
deployment.
● Part 4, “Beyond the Upgrade,” consists of chapters 17 – 21 and covers what to do
after 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 functional
equivalence in Visual Basic .NET. The information in this chapter includes
suggestions for advancing the architecture, design, and implementation of
your applications.
● Chapter 18, “Advancements for Common Scenarios,” suggests advancements
that are based on specific application types, such as forms applications and
enterprise services.
● Chapter 19, “Advancements for Common Web Scenarios,” is a continuation of
Chapter 18 that focuses on advancements for Web-based applications.
xx Preface
● Chapter 14, “Interop Between Visual Basic 6.0 and Visual Basic .NET”
Document Conventions
This guide uses the style conventions and terminology shown in Table 1 on the
next page.
xxii Preface
Note: There is a community site for this guide on GotDotNet. This site contains a “Downloads”
section where you can obtain the Visual Basic 6.0 Upgrade Assessment Tool that is described
in this guide. It also contains forums where you can post feedback, ask questions, or provide
suggestions.
Principal Authors
The 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
Contributors
The Visual Basic 6.0 Upgrade Assessment Tool and the Upgrading Visual Basic 6.0 to
Visual Basic .NET and Visual Basic 2005 guide were produced with the help of the
following people.
● Program Manager: William Loeffler (Microsoft Corporation)
● Test: Edward Lafferty (Microsoft Corporation); Ashish Babbar, Terrence Cyril J.,
Manish Duggal, Chaitanya Bijwe, Arumugam Subramaniyam, Umashankar
Murugesan, Dhanaraj Subbian, Tarin R. Shah, Dipika Khanna, Gayatri Patil, and
Sandesh Pandurang Ambekar (Infosys Technologies Ltd)
● Documentation and Samples: RoAnn Corbisier (Microsoft Corporation); Tina
Burden McGrayne and Melissa Seymour (TinaTech Inc.); Sharon Smith (Linda
Werner & Associates Inc.); Francisco Fernandez and Paul Henry (Wadeware LLC)
Acknowledgements
Many thanks to the following individuals who provided invaluable assistance
during the development of this guide:
● Dan Appleman (Desaware Inc.)
● Billy Hollis
More Information
For more information about the Visual Basic 6.0 Upgrade Assessment Tool and to
download it, see “Visual Basic 6 to Visual Basic .NET Migration Guide” on
GotDotNet:
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.
1
Introduction
Before investing time, money, and energy into an upgrade project, it is important
to understand why an upgrade is beneficial. It is equally important to understand
potential upgrade strategies to minimize costs and risks. This chapter presents the
benefits 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.
● To reduce the cost of ongoing business activity. For example, the increased
scalability and performance of applications that are upgraded to Visual Basic
.NET, and the increased productivity of developers, can reduce the costs of
regular 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 does not have enough resources to support the application.
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 quality
as a business tool and the quality of the source code that implements it. This is an
assessment of the effective value of the application from the view of the user and
the developer. The user requires an application that is stable, that does the job
well, and that is easy to use. A developer requires an application with code that is
understandable, well-documented, and not unnecessarily complex.
Making the following three assessments will help you gather the information that
you need to make a decision about upgrading your application. They will also help
you accurately estimate the effort that is needed to select and complete the appropri-
ate upgrade process:
● Business value assessment
a new language version, such as Visual Basic .NET, may increase user apprecia-
tion. Similarly, an application that coordinates with other applications must have
clean data transmission. It should use dependable data formats and communica-
tion protocols. Newer languages often support improved transmission protocols
or data formats that make inter-application communication simpler and more
reliable.
● 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 dependent
on your application, and there are not any third-party products to replace your
application, the value of your application is high. Ensuring the future of the
application 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 are
unavailable 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 to
be very valuable. In contrast, an application that processes large amounts of
business data will be highly valuable. Even applications designed to assist
employees 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.
● Complexity metrics. The assessment tool recognizes the same things that cause
the upgrade wizard to generate errors, warnings, and issues (EWIs). These EWIs
imply specific modifications that are required to resolve them. The assessment
tool assigns complexities to these EWIs. This helps you estimate the work that
needs to be performed to remedy all of the reported issues.
● Dependency diagrams. The assessment tool generates the call graphs for each
function 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 to
build them. If you are considering upgrading your applications with the Visual Basic
Upgrade Wizard, you should be aware of some of the tool’s 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 that
are 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 also
not supported in Visual Basic .NET.
● A database project that uses data binding to bind data sources to 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 same
functionality within Visual Basic .NET. A more complete list of features that are not
automatically 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 allow
time to identify and analyze upgrade alternatives for the technologies involved. You
should 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 original
application. If any development initiatives are currently in progress, the code will be
less stable. The code may contain bugs, incomplete features, or even invalid code
that will not compile.
The best time to upgrade is when the application code base is stable but is due for
enhancements. This strategy gives you the opportunity to combine the upgrade
effort with feature enhancements. In contrast, it is best to avoid upgrading your
applications when undergoing a period of intense change, unless you have a very
strongly controlled code management process. Upgrading a large application may
take several weeks or even months. During this time, changes made to the original
code 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 likely
to result in a disparity between the two versions of the application. If you decide
that it is necessary to make changes to the original applications while you also
upgrade 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 application
with a well designed, implemented, tested, and documented code base that has
drifted away from the business needs (either through revisions in the application or
changes to the business) is a prime candidate for upgrade. On the other hand, such a
stable application that does fulfill the business needs and does not require improve-
ments is probably better left in its original form. An application of poor quality with
a weak design, complex implementation, and/or poor documentation is also a good
candidate for an upgrade. Upgrading an application of poor quality to a new devel-
opment language, such as Visual Basic .NET, gives you the opportunity to correct
these shortcomings. This will make it easier to maintain and will possibly advance
the application.
also need to be upgraded to Visual Basic .NET. This is especially true if the testing
process is performed with automated tools.
If the developers do not have previous knowledge of the application, you must
factor extra time for them to understand the design and implementation of the
application. The time that is required also increases if the application does not have
an adequate set of documentation.
Use the following lists of indicators to help you choose an option for updating all or
part of your application:
● Indicators for choosing to upgrade. These include:
● Only simple Web access is required, which allows you to use a wrapping
solution
● You have sufficient resources to maintain core legacy code.
● The time, cost, and disruption of rewriting the application are acceptable.
Figure 1.1 on the next page provides a visual summary of these indicators. To use
this graph, you need to first determine where your current application stands in
terms of business value and quality.
10 Upgrading Visual Basic 6.0 Applications
Custom
Rewrite Migrate
Business
Value
Replace Reuse
Standard
Low High
Application Quality
Figure 1.1
A visual guide for deciding when and how to upgrade an application
Business value is the vertical access on the left. If your application provides some
level of “standard” functionality that is easily found in other applications, particu-
larly third-party off-the-shelf products, it will be located lower down on this axis. If
your application is a custom built application whose functionality is unique to your
business needs, it will appear higher up on this axis.
The horizontal axis at the bottom represents the quality of an application from the
points of view of both the user and the developer. If your application is difficult to
use, slow, unstable, or gives inconsistent results, the user will see it as a low quality
application. If the code is complex and difficult to maintain, the developer will see it
as low quality. In both cases, the application will be located to the left of the applica-
tion quality axis. If both users and developers are happy with the application, it will
be located to the right of this axis.
After you determine where the application stands on both axes, you can determine
the best course of action for updating your application. In general, applications that
provide “standard” functionality are candidates for replacement or reuse while
applications that provide “custom” functionality are candidates for rewriting or
upgrading. Low quality applications should be replaced or rewritten while high
quality applications should be reused or upgraded.
When indicators are in favor of an upgrade, choosing to upgrade to Visual Basic
.NET will best leverage the existing code base. For more information about some of
these benefits, see the “Moving from Visual Basic 6.0 to Visual Basic .NET” section
later in this chapter.
Partial Upgrade
So far, this chapter has discussed the updating of your application as an all or
nothing undertaking. You can upgrade it or you can leave it as it is. You can rewrite
it or you can replace it. However, for many applications it is not a straightforward
question of choosing one of the four options previously listed. In some cases, you
Chapter 1: Introduction 11
Upgrade Strategies
If you decide that the upgrade option is the right approach to update your applica-
tion, you also need to choose an appropriate upgrade strategy. For information
about possible strategies, see the “Selecting an Upgrade Strategy” section in Chapter
2, “Practices for Successful Upgrades.”
Increased Productivity
The Visual Basic .NET language contains many new language features that increase
developer productivity. This section explores some of these features, and explains
how they benefit application development.
12 Upgrading Visual Basic 6.0 Applications
Visual Basic .NET is built around the .NET Framework. Many of the benefits
of Visual Basic .NET are derived directly from the .NET Framework itself.
Microsoft .NET Framework is based on a specification named the Common Lan-
guage Specification (CLS). This specification defines the rules that determine a
minimum set of features that all .NET languages, including Visual Basic, must have.
Included among this minimum set of features are certain object-oriented features,
such as inheritance and exception handling. These features are not available in
earlier versions of Visual Basic. It also specifies which format the compilers create
for the executables, and it ensures that your application will run on any .NET engine
on any platform without recompilation.
The result is that code is compiled to a special format named Microsoft Intermediate
Language (MSIL) instead of the usual platform-specific machine code. MSIL
executables are then compiled to a platform-specific machine code at run time
through just-in-time (JIT) compilation. The benefit of this approach is that a single
compilation of your application is optimized at run time based on the actual proces-
sor and/or operating system on which the code is currently executing. For example,
a .NET application is optimized and run as a 32-bit application on the standard 32-
bit edition of the Microsoft Windows® XP operating system. The same application is
optimized and run as a 64-bit application, without the need for recompilation, on the
64-bit edition of the Microsoft Windows Server™ 2003 operating system. Because
this is a published specification, it is possible that new processors and operating
systems can have .NET run-time engines created for them as they are released. This
means that an application written for the .NET Framework can run on and be
optimized for new hardware or operating systems without any recompilation or
upgrading of the application. A multi-platform version of an application or compo-
nent means developers can solve new problems, instead of investing time porting
existing components.
Additionally, the MSIL contains metadata about the classes that it contains. The
result is that developers do not have to create “include files,” type libraries, Interface
Definition Language (IDL) code, or any other additional files to use these classes in
another application. The client application can automatically extract this information
from the MSIL. This makes sharing and using the MSIL a lot easier. Productivity
increases because it is easier to take advantage of existing classes.
The main component of the CLS implementation is named the common language
runtime (CLR), which is the engine on which all .NET applications run and which
enables the interoperability and integration between all .NET languages. The man-
agement of resources (such as memory, threads, exceptions, and security) for .NET
applications is handled automatically by the CLR. Applications that are built using
only .NET technologies are referred to as managed applications or managed code.
The term managed derives from the fact that resources in such applications are
Chapter 1: Introduction 13
managed by the CLR. Developers who build managed code benefit from the delega-
tion of responsibilities to the CLR because it frees them to focus on the application
logic instead of low level logic of resource management. This allows software
developers to be far more productive because they can concentrate on solving
business problems.
The data typing rules are defined by a section of the CLS named the common type
system (CTS). This specification defines all of the .NET data types and their behav-
iors. As a result, all languages in .NET share a common set of base data types whose
storage requirements and functional behaviors are identical across all languages. For
example, a string is the same regardless of whether it is defined in a Visual Basic
.NET module, a managed Visual C++® library, a Visual C#® component, or a Visual
J#® package. The benefit is that the specification ensures that a parameter that is
passed from a Visual Basic .NET application to a Visual C# library will be inter-
preted correctly within the library, and the return value will behave as expected back
in the Visual Basic .NET application. The fact that the application and the library it
uses are written in two different languages is transparent to the developers of each.
This benefit results in increased productivity because Visual Basic .NET developers
can now more easily integrate existing libraries and components into their Visual
Basic .NET code, even when those libraries are developed in other languages.
An additional benefit of the CTS is that it enables any class written in a .NET lan-
guage to inherit behavior from a class written in any other .NET language. For
example, you can create a Visual Basic .NET class that inherits behavior from an-
other class that was developed in Visual C#. Moreover, you can extend the .NET
Framework itself from Visual Basic .NET. This significantly expands the set of
components that you can use and the ways in which you can use them. The increase
in productivity results from code reuse, even among different languages.
Applications built for the .NET Framework have access to a comprehensive class
library named the .NET Framework Class Library (FCL). It contains a large number
of classes that enable all categories of client and server application development.
The FCL contains classes for programming security, cryptography, Windows Forms,
Windows services, Web services, Web applications, I/O, serviced components, data
access to SQL Server™ and many other database systems, directory services, graph-
ics, printing, internationalization, message queues, mail, common Internet technolo-
gies and protocols, culture-specific resources, COM interoperability, .NET remoting,
serialization, threading, and transactions. The benefit of the FCL is that Visual Basic
.NET developers can use and expand existing components built on the FCL without
having to start from the beginning.
In Visual Basic .NET, the CLR is responsible for memory management. In particular,
the CLR manages the work of freeing up memory for objects that are no longer
referenced in an application. This process, garbage collection, happens automatically
any time the CLR runs low on memory. The benefit of this process is that developers
do not have to destroy unnecessary objects to free memory resources. This results in
14 Upgrading Visual Basic 6.0 Applications
increased productivity because a developer can invest more time in solving business
problems than in resource management issues.
Although Visual Basic 6.0 provided an object-based programming model, it lacks
some features that would make it a full object-oriented language. In particular,
Visual Basic 6.0 does not provide full inheritance. Although it supports interface
inheritance, this limited form prevents developers from taking advantage of the all
of the benefits of this object-oriented programming. For example, this type of inher-
itance does not allow for code reuse and it limits the ability to fully implement
object-oriented designs.
Visual Basic .NET supports full implementation inheritance. You can create new
classes that inherit from existing classes. In fact, you can perform implementation
inheritance regardless of the .NET programming language that was used to create
the super class. This means that you can now more fully reuse existing classes
through inheritance and can truly implement object-oriented designs.
In addition to implementation inheritance, Visual Basic .NET still supports interface
inheritance. An interface is defined with the Interface keyword. Your classes then
inherit from an interface by implementing its methods.
Furthermore, you can create forms that inherit from existing forms. This type of
inheritance is named visual inheritance, and it allows you to apply the layout,
controls, and code for existing forms to new forms. Through this form of inherit-
ance, developers can build standard base forms. These forms can then be inherited
by applications to give them a similar look and style, but it still gives the application
developers the freedom to expand the form by adding new controls or changing a
particular control’s behavior. The result of visual inheritance is that developers can
take existing forms and customize them for new applications, instead of having to
recreate new forms for each application.
The benefit of inheritance is that it enables code reuse. Developers can take existing
classes and forms, and through inheritance, customize them to meet an application’s
needs. The result is increased productivity because less time is invested in building
completely new components.
Visual Basic .NET includes support for a new form development system named
Windows Forms. The Windows Forms framework provides features that make the
creation of powerful forms-based applications easy. These features include all
standard Windows application form controls (such as buttons and text boxes), built-
in support for connecting forms to XML services, and ActiveX controls support.
These are only a few of the many features available in Windows Forms. The benefit
of this framework is that it allows developers to rapidly build forms applications.
Chapter 1: Introduction 15
Control anchoring frees developers from writing code to deal with form resizing.
Now, controls on a form can be visually anchored so that they remain a fixed length
from the edge of the form and resize whenever the form resizes, with no effort on
the part of the developer. This frees the developer to focus on business logic, instead
of form manipulation, which makes the developer more productive.
For Web applications, Visual Basic .NET includes built-in support for Web Forms
and XML. These features increase productivity by simplifying the work that is
required to include them in your applications. You can even extend a functional
application into a Web service. Moreover, the Visual Studio .NET IDE includes
design tools that help to quickly and efficiently design HTML documents, as well as
XML documents and schemas. All these features provide you with an environment
in which the effort to build a Web application development is comparable to devel-
oping a Windows-based application.
In addition to the beneficial features in the Visual Basic .NET language itself, there
are productivity benefits to using the standard .NET IDE, Visual Studio .NET. Some
of these features are highlighted here.
The Windows Forms Designer gives developers all the tools they need to rapidly
design forms. Controls such as buttons, check boxes, and more can be added to a
form by dragging them to the form.
Visual Studio .NET also provides a WYSIWYG (what you see is what you get)
designer for Web pages. This enables developers to quickly design Web-based
solutions. Also, as previously mentioned, XML designers provide tools for rapidly
building XML enabled solutions.
Visual Studio .NET provides a Task List display, which shows the outstanding tasks
the developers need to complete. The Task List indicates any ToDo comments that
developers include in code as a way to remind themselves of these outstanding
tasks. The Task List provides a centralized view of these reminders, and allows
developers to jump immediately to the comment when the time to address the task
arrives.
The Task List also displays any compilation errors that need to be corrected. The
Visual Basic .NET compiler continuously works in the background during coding.
Compilation errors are flagged in real time with blue squiggle underlines in the
code. The Task List also updates in real time the list of compilation errors to give
developers a complete list of corrections that they need to make.
The Task List can also be filtered to show only particular types of outstanding tasks,
such as showing only compilation errors or only ToDo comments. Figure 1.2 on the
next page shows a typical Task List in a Visual Basic .NET solution.
16 Upgrading Visual Basic 6.0 Applications
Figure 1.2
ToDo comments in the Task List
The background compilation and Task List features enable developers to be more
productive by reminding them of unfinished tasks.
As mentioned earlier, the .NET Framework is designed for cross-language
interoperability. Controls and components written in one language can easily be
used in another language because the CLR unifies all data types. Anyone who has
struggled to get a Visual Basic 6.0 user control to work in a Visual C++ project can
recognize the benefits of this interoperability. Not only can you easily use a compo-
nent written in another .NET language, you can also inherit from a class written in
any other .NET language. You can also create components in other languages that
inherit from your Visual Basic .NET classes. Surprisingly, this interoperability does
not complicate development. Visual Studio .NET provides a single environment
for developing and compiling multi-language applications. A Visual Studio .NET
solution can contain several projects, where each project can be developed using a
different .NET language. Using the unified debugger, you can step through the
various components, even if they were written in different languages. You can also
debug COM+ services and step into SQL Server stored procedures.
A new feature of Visual Studio .NET is the Processes dialog box that allows you
to attach to and debug an already running process. Certain types of applications
require specialized execution environments that Visual Studio is unable to provide.
For example, a Windows service execution is handled by the Windows Services
Manager. Such applications do not have graphical user interfaces. Although it is
possible in some cases to provide a Windows service with a Main method and an
Chapter 1: Introduction 17
Better Integration
Visual Basic .NET is designed to easily interact with components built on the .NET
Framework and with legacy components. This section explores how improved
integration can benefit applications.
Assemblies are the fundamental unit of deployment in .NET. An assembly is a
collection of types and resources that form a logical unit of functionality, such as a
component or application, in the form of a dynamic link library (DLL) or executable
18 Upgrading Visual Basic 6.0 Applications
(EXE). An assembly also maintains information used by the CLR, such as the version
number of the assembly, the names of other assemblies it is dependent on, and
requests for security permissions.
An important part of being able to maintain and control dependencies between
components of an application is the ability to publish public interfaces that define
how the components can be used. This is important because it allows the developer
of a component to modify it, to improve it, or fix problems, without breaking code
written by clients of the component. Assembly isolation allows the component
developer to ensure that only a predefined subset of the component can be used
directly by clients. This allows the developer to make changes to the implementation
of the component without causing problems for or requiring changes to the clients,
as long as the public interface does not change.
Another benefit of assembly isolation is that it allows side-by-side execution. Side-
by-side execution refers to the ability to install multiple versions of an application,
third-party components used by an application, or the .NET Framework itself and to
have clients choose which version of the framework and/or components it uses at
run time. This results in better integration because developers no longer need to
worry about corrupting existing applications with the release of newer versions of
a module, component, or framework. Assemblies cannot corrupt each other, and
clients always know the correct version of an assembly to refer to.
Visual Basic .NET includes features that allow interoperability with COM compo-
nents. COM interop allows developers to create a bridge between managed Visual
Basic .NET code and the unmanaged code of a COM component for all basic data
types, such as numeric types and strings. Data types of parameters passed to and
return values received from COM components are converted to the proper equiva-
lents between the managed and unmanaged code. This mechanism, referred to as
data marshaling, ensures clean interoperability between the managed code of your
upgraded application and the unmanaged code of the COM component. Note that
in some instances, custom code for performing marshaling may be required for user-
defined types.
Application Extendibility
Extending an application with new technologies helps to leverage the investment in
that application. Visual Basic .NET includes many features that ease the process of
extending an application with additional technologies.
Visual Basic .NET supports multiple distributed technologies. One such technology
is Web services, an open standard that enables developers to expose a set of software
services over the Internet through XML. The .NET Framework provides built-in
support for creating and exposing Web services. Software services exposed in this
way are both scalable and extensible and embrace open Internet standards — HTTP,
XML, SOAP, and Web Services Description Language (WSDL) — so that a service
Chapter 1: Introduction 19
can be accessed and consumed from any client or Internet-enabled device. Support
for Web services is also provided by ASP.NET.
Another example is a new technology unique to the .NET Framework named .NET
remoting. Remoting is similar to DCOM. It enables communication between applica-
tions. This communication can occur between applications on the same computer,
between applications on different computers on the same network, and even be-
tween applications on different computers across different networks. Support for
.NET remoting is available in Visual Basic .NET.
Improved Reliability
Some of the new features in Visual Basic .NET improve the reliability of components
and applications. This section describes some of these features and how they result
in improved reliability.
In Visual Basic .NET, data types are bound statically. This means that the type of a
variable must be known at compile time. Using this strategy, the compiler can verify
that only valid operations can be applied to a particular variable or value. The strict
data typing rules that are enforced by Visual Basic .NET and the CTS are not just to
provide a high level of compatibility between different languages. These rules also
create a development platform where errors caused by incorrect use of data are
identified as early as possible in the development life cycle, typically at compile
time. The increased interoperability of data types across components and strict
enforcement of data typing rules in Visual Basic .NET result in more reliable applica-
tions and components.
Visual Basic .NET helps you reduce programming errors by supporting stronger
type checking. For example, using the wrong enum value for a property or assign-
ing an incompatible value to a variable is detected and reported by the compiler.
Also, with ADO.NET, you can add typed datasets to your application. If code refers
to an invalid field name, it is detected as a compile error instead of a run-time error.
The earlier an error is found during the development cycle, the easier it is to correct.
Identifying type errors at compilation time instead of at execution time makes them
easier to correct.
It is possible to force even stronger type checking at compile time by using Option
Strict On in your application code. This option completely prohibits late binding
and requires you to use conversion functions whenever you assign to a variable a
value that is of a different type. This helps developers identify points in their code in
which subtle errors due to conversion may occur, such as the loss of a value due to
truncation when assigning a higher-precision value to a lower-precision variable (for
example, assigning a Long value to an Integer variable).
Another new feature of Visual Basic .NET that results in improved reliability is a
security feature that enforces the adherence to object-oriented concepts such as the
20 Upgrading Visual Basic 6.0 Applications
encapsulation of data and behavior. This feature, named type safety, protects memory
locations by restricting access to private members of an object. It ensures that when a
field or method is marked as private, it may be accessed only within the class to
which it belongs.
The term type safety also has a broader meaning that refers to language features that
reduce the number of run-time errors that relate to incorrect data types. In this
context, type safety refers to the compile-time checks that ensure operations are
performed on appropriate data type values.
In contrast, the type safety that is used to ensure .NET security is checked by the
compiler and can optionally be verified at run time using verification. Verification is
required because the runtime has no control over how various assemblies in the
application were compiled, but they may be skipped if the code in question has
permission to bypass verification. This kind of type safety guarantees that a class’s
public interfaces are respected, and that assemblies can be isolated from other
assemblies in the application domain. This improves reliability and security because
no other code can adversely affect execution by altering data or invoking functional-
ity that has been marked private. For more information about type safety and
verification in .NET, see “Type Safety and Security” in the .NET Framework
Developer’s Guide on MSDN.
Structured exception handling is another new feature of Visual Basic .NET that can
improve application reliability. In addition to supporting the familiar On Error
GoTo error catching mechanism from Visual Basic 6.0, Visual Basic .NET provides a
new structured error handling mechanism: the Try/Catch/Finally block and the
Throw statement.
A Try/Catch/Finally construct encloses code that may result in errors or other
exceptional conditions, and it provides handlers for each potential exception. A
software developer has full control over the granularity of the exception handling,
from an individual line of code, to an entire block of code, to all the code in a func-
tion. The developer also has control over the types of exceptions that are handled,
from specific exceptions to general catch-all exceptions. The optional Finally portion
of the construct provides a way to specify code that should execute regardless of
whether or not an exception occurred.
The Throw statement is a way for a developer to signal the occurrence of an errone-
ous or exceptional condition. This allows the developer to signal to a client that an
unexpected condition has occurred, and it gives the client the opportunity to decide
how to deal with the condition. A client may be able to recover from the condition or
provide a strategy to allow an application to gracefully degrade.
Structured exception handling gives developers a way to either recover from or
gracefully exit on error conditions. These strategies can help to prevent data loss;
this improves an application’s reliability even in the event of error.
Chapter 1: Introduction 21
Improved Security
Application security is an important feature of Visual Basic .NET. The .NET Frame-
work provides a set of sophisticated security features without overcomplicating
requirements for developers. Security management in the CLR prevents others from
modifying the assemblies that contain an application or its dependent components.
It also ensures that components cannot access memory that they are not authorized
to access.
Developers can control the permissions of applications and components that use
configuration files. A developer can control access to a resource based on the privi-
lege level of the user running an application or based on the trust level of the appli-
cation itself. This can restrict untrusted code from accessing a resource even if the
user of the code would ordinarily have full access. For example, even if untrusted
code runs within a super-user account, its access to a resource can still be restricted.
● A new type of installer called a merge module provides a much simplified way to
package and install components that will be shared by multiple applications.
Merge modules (.msm files) allow you to share components between multiple
deployment projects. You can create your own merge modules with Visual Studio
.NET, or you can use existing merge modules that are available for many stan-
dard components from Microsoft, as well as from third-party vendors. A merge
module is created once and is included in all applications that use it. It handles
all the details of remembering which applications are using the component and
when the last application that needs it has been uninstalled. For more informa-
tion about merge modules and other installation and deployment options, see
Chapter 16, “Application Completion.”
One of the results of improved deployment features in Visual Basic .NET is that
installations can no longer corrupt other application installations.
Increased Performance
Some new features of Visual Basic .NET can be used to increase the performance of
an application. This section explores some of these features and how they can be
used to increase performance.
A typical Visual Basic application is single threaded, which means that only a single
task at a time can be performed. However, Visual Basic .NET now provides support
for multithreaded applications, so that multiple tasks can execute concurrently.
Multithreading can improve application performance in the following ways:
● Program responsiveness increases because the user interface can remain active
while other work continues.
● Idle tasks can yield their designated processor time to other tasks.
Technical Support
As of March 2005, Microsoft ended the mainstream phase of support for Visual Basic
6.0, and entered into a period of extended phase support. The current extended
phase support is available until March 2008, at which point Visual Basic 6.0 will no
longer be supported.
Chapter 1: Introduction 23
The impact of these support policies is that free support for Visual Basic 6.0 is no
longer available. During the extended phase, customers can still receive professional
product support for Visual Basic 6.0 through telephone and online incident support
channels on a per-incident fee basis or through Premier Support. Similarly, critical
updates and hotfixes are only available for a fee during the extended phase.
For more information about the support policies for Visual Basic 6.0, see “Product
Family Life-Cycle Guidelines for Visual Basic 6.0” in the Microsoft Visual Basic
Developer Center on MSDN.
Benefits of the Visual Basic 6.0 to Visual Basic .NET Upgrade Wizard
If you choose to upgrade your application, you can best achieve this by using the
Visual Basic 6.0 to Visual Basic .NET Upgrade Wizard included in the Visual Studio
.NET IDE. By using the upgrade wizard to upgrade your application, you can:
● Produce source code that is both easily extendable and maintainable.
● Acquire functional equivalence, with all of the built-in features of the original
program intact.
● Gain a robust and intelligent automatic restructuring of the code.
Some of these benefits may be reduced or lost if an application uses many technolo-
gies that are not supported in Visual Basic .NET. The Visual Basic 6.0 Upgrade
Assessment Tool can help to identify an application’s dependence on such technolo-
gies, and this guide provides the solutions for addressing dependence on unsup-
ported technologies in Visual Basic .NET.
Summary
When you decide whether to upgrade Visual Basic 6.0 applications to Visual Basic
.NET, you have many factors to consider. Some applications are not well suited to an
upgrade, either because they will not benefit from .NET technologies or because the
cost or complexity of the upgrade is prohibitive. Other applications practically
compel the move because the benefits far outweigh the costs. The main point of this
chapter is that an upgrade should be considered on a per-application basis. There
are many convincing reasons for upgrading applications to Visual Basic .NET, but
there are often just as convincing reasons to leave an application alone. Upgrade an
application only if and when it makes sense to do so. If an upgrade is warranted,
risks and costs can be minimized by preparing an upgrade plan. The remaining
chapters of this guide provide you with the tools and techniques to prepare such a
plan, and to help you perform the actual upgrade as efficiently as possible.
24 Upgrading Visual Basic 6.0 Applications
Functional Equivalence
Functional equivalence is an important concept for any upgrade project. In the
context of a Microsoft Visual Basic upgrade, achieving functional equivalence means
that the exact functionality of a Visual Basic 6.0 application is retained in the Visual
Basic .NET application after it has been upgraded, but before new features are
added. Achieving functional equivalence guarantees that your application logic does
not change as a result of the upgrade and that your existing business rules are
functional in the upgraded application.
By making functional equivalence a goal for your upgrade project, your organiza-
tion can benefit in several ways:
● Because your Visual Basic .NET application is functionally equivalent to the
original Visual Basic 6.0 application, you have a perfect specification for the
application upgrade project. This means that you can easily identify discrepan-
26 Upgrading Visual Basic 6.0 Applications
cies in application behavior and in output, and you can clearly measure the
success of the upgrade project.
● With a functionally equivalent application, you will not encounter scope in-
creases or changes, and you can predict and facilitate the testing phases of the
project. You will still need to prepare specifications for any new functionality that
is added after functional equivalence is achieved.
● The goal of achieving functional equivalence gives you a clear, easy-to-under-
stand means of tracking the progress of the project. As you upgrade parts of your
application, you can compare the functionality with the original application.
● A functionally equivalent application eliminates the need for existing users to
adapt to an upgraded application and reduces any change management processes
to the IT department.
● Achieving functional equivalence is the fastest way for an organization to transi-
tion from older to newer technology. It is also the most efficient way for an
organization to regain autonomous control and to resume normal incremental
maintenance of the application.
Application Advancement
Achieving functional equivalence provides you with a working .NET version of
your application, but it is usually considered an intermediate step in the process of
upgrading an application. As described in Chapter 1, “Introduction,” a principal
benefit of upgrading your application to the .NET Framework is that you have
access to significantly improved application performance, integration, productivity,
extensibility, reliability, and security. Using this new technology to add or improve
functionality in your application is referred to as application advancement.
Application advancement involves identifying, and then modifying or extending,
the areas of your application that would benefit from the many improvements that
the .NET Framework offers. In fact, application advancement could be considered to
be the key reason for upgrading to Visual Basic .NET in the first place. However, it
might seem that you are wasting effort by first achieving functional equivalence in
an application that you ultimately plan to change, but by doing this, you are actually
providing a solid basis for a more controlled approach to application advancement.
Advance
Deploy
Test
Upgrade
Prepare
Plan
Figure 2.1
A graphical representation of the upgrade process.
28 Upgrading Visual Basic 6.0 Applications
The main phases of the upgrade process are planning, preparation, upgrade, testing,
deployment, and advancement. They are briefly described here and will be explored
in more detail later in this chapter:
● Planning. Planning is the first phase of the upgrade project. It involves defining
goals, expectations, and constraints. Planning requires that you assess the appli-
cation to be upgraded so that you can evaluate risks and determine the steps
needed to upgrade the application. It is particularly important for you to deter-
mine the order in which the modules should be upgraded. During the planning
phase, you will also need to evaluate the cost of upgrading the application.
● Preparation. The second phase involves preparing your application for the
upgrade. Although the preparation phase is optional, it is strongly recommended
because by preparing your application in advance you will save a great deal of
time during the upgrade phase. Preparing your application includes modifying
certain implementation details of the application so that the process of using the
Visual Basic Upgrade Wizard is as efficient as possible. This, in turn, reduces the
work you need to do after the upgrade wizard has been used.
● Upgrade. During the upgrade phase, you use the upgrade wizard to upgrade as
much as possible of the Visual Basic 6.0 code to Visual Basic .NET code. After-
ward, you manually upgrade the remaining code. The result of this phase should
be a Visual Basic .NET application that is functionally equivalent to the Visual
Basic 6.0 application.
● Testing. Usually, testing is the basis for demonstrating functional equivalence in
your application. Although listed here as a phase to follow the upgrade phase,
testing should be performed throughout the process, even in the early stages of
the upgrade. For example, unit testing can be applied to individual components
as they are upgraded to ensure they are correct before testing their behavior in
the entire system.
● Deployment. Because deployment also must be tested, the deployment phase
often overlaps with the upgrade and testing phases. This is especially true for
projects that require a successfully deployed application before the testing phase
can be completed.
● Advancement. The final phase involves advancing your functionally equivalent
application by implementing new .NET features or by improving existing fea-
tures with .NET functionality. Keep in mind that any new features will also have
to undergo testing.
Before you begin the project in earnest, you might consider using a subsection of
your application in a test run of this process. A test run can hone your cost estima-
tions and possibly reduce upgrade risks by identifying issues that could block the
progress of the actual project.
Chapter 2: Practices for Successful Upgrades 29
Proof of Concept
When planning your project, you should evaluate the need to test any major up-
grade issues with a proof of concept or with a prototype. A proof of concept is
evidence that demonstrates whether a project is ideal or feasible. It, or a prototype,
can help you to avoid wasting time on poor coding decisions and can allow you to
validate solutions in an isolated condition. A proof of concept will help you to
determine the real cost of the most common issues that appear in the upgrade
wizard’s upgrade report. For more information about the upgrade wizard, see
Chapter 5, “The Visual Basic Upgrade Process.”
The proof of concept for an upgrade project will help you familiarize yourself with
details of the upgrade process. A good way to develop a proof of concept is by
upgrading a practice application. When choosing a practice application, consider a
simple application that is a good candidate for use with the upgrade wizard and one
that is not tightly integrated with other technologies. (For more information, see the
“Performing an Application Analysis” section later in this chapter). After you have
chosen and then upgraded the practice application, you and your team can gain
valuable experience by analyzing and solving generic issues in the upgraded code.
This activity will help you to identify issues that can affect the execution of your
more complex, real-world project. Learning to upgrade is like learning anything
else: by starting with a simple project, you learn in manageable pieces. Also, because
you will probably have the application upgraded and running quickly, your team
will build the confidence that is needed to tackle a larger project. Finally, this prac-
tice upgrade will help you to assess the feasibility of upgrading a larger, more
complicated application.
If the proof of concept convinces you of the feasibility of upgrading a more complex,
real-world application, choose one that will benefit from the new features of the
.NET Framework so that you can review the process from the point when the appli-
cation has achieved functional equivalence through the final phase of application
advancement. Think about the way the architecture is going to be modified. For
large applications, the principle of divide and conquer applies. You should upgrade
the application module-by-module. For example, you may start with the client
modules, and then move up the dependency hierarchy by next upgrading the
business logic and data tier modules. (For more information about upgrade strate-
gies, see Chapter 1, “Introduction.”) As you move along in the process, be sure that
you test each module of the application as it is upgraded so you know that you have
quality code before you move forward.
After you and your team have had some experience with the upgrade process and
you have chosen a real-world application to upgrade, you will be ready to begin the
work of defining the scope of the project.
30 Upgrading Visual Basic 6.0 Applications
Note: If you plan to upgrade your application one piece at a time, you must apply
interoperability techniques that allow the components that remain in Visual Basic 6.0 to
communicate with the upgraded Visual Basic .NET components. For more information about
interoperability, see Chapter 14, “Interop Between Visual Basic 6.0 and Visual Basic .NET.”
and the solutions that are recommended for resolving them. Remember, you can
reduce the number of issues that need to be addressed by preparing your Visual
Basic 6.0 code before applying the upgrade wizard. For more information about
using the upgrade wizard, see Chapter 5, “The Visual Basic Upgrade Process.”
The purpose of the application analysis is to generate information that will be used
to estimate the effort of the upgrade project and to create a technical profile of the
application. The output of application analysis should cover the following items:
● Current and target architecture
● Inventory to upgrade
Complete Upgrade
With a complete upgrade, all components of your application are upgraded and
deployed as a whole. This does not mean they are upgraded in parallel; it means
only that no effort is made to deploy the application in a production environment
until all components have been moved to .NET. This strategy may require significant
effort, and therefore it can be very expensive. It not only involves upgrading code
from Visual Basic 6.0 to Visual Basic .NET, but also upgrading all of the technologies
to their .NET equivalents when they exist, or applying alternative technologies
when they do not. For applications that do not make significant use of deprecated
technologies, a complete upgrade can be very fast and inexpensive. The more
dependent an application is on dated technologies, the more expensive and time
consuming the upgrade process becomes.
This strategy has the following advantages:
● Upgraded applications can be advanced with new functionality that uses .NET
technologies and techniques. Examples and strategies of this can be found in
Chapter 17, “Introduction to Application Advancement,” Chapter 18, “Advance-
ments for Common Scenarios,” Chapter 19, “Advancements for Common Web
Scenarios,” and Chapter 20, “Common Technology Scenario Advancements.”
Chapter 2: Practices for Successful Upgrades 35
Staged Upgrade
Unlike a complete upgrade, where all pieces of the application are upgraded in a
single complex process, a staged upgrade strategy allows a more controlled, gradual
upgrade where the application is upgraded a part or component at a time. Each
newly upgraded component can be rolled out as it is upgraded, instead of waiting
for the complete upgrade of the entire application. This strategy is only possible
when the existing application is composed of multiple distinct components, each
36 Upgrading Visual Basic 6.0 Applications
have the basic infrastructure that will make it possible to continue with the upgrade
of other applications using the same vertical approach — or to extend the updated
portion of the original application.
Horizontal Upgrade
In a horizontal upgrade strategy, you upgrade an entire tier of your application to
Visual Basic .NET without immediately upgrading the other tiers. By upgrading a
single tier at a time, you can take advantage of the specific features that the .NET
Framework provides for that particular tier, in many cases without modifying
application code or affecting the operation of other application tiers. Deciding which
tier to upgrade first is the first step in a horizontal upgrade strategy.
Middle-tier COM components can be upgraded to Visual Basic .NET with few or no
changes to the presentation tier. You should consider the following points when
deciding if a horizontal upgrade strategy is appropriate, and if so, which tier is the
most suitable to upgrade first:
● Your application is on a large number of Web servers. A prerequisite for the
deployment of a Visual Basic .NET application is that the common language
runtime (CLR) must be installed on each Web server. If your application is de-
ployed on a large number of servers in a Web farm configuration, this can be an
issue. If you have relatively fewer servers in middle tiers than in other tiers,
consider using a horizontal upgrade and then upgrading the middle tier first.
● Your application uses a large amount of shared code. If your Visual Basic
application uses a large number of DLLs or other types of shared code, constants,
or custom libraries in the middle tier, choosing to upgrade this tier first can help
you manage the upgrade of your entire application. However, if you do this, you
will destabilize a large number of components that use the shared code and
thereby affect the testing process.
● Your application has a complex middle tier. Complex object hierarchies in the
middle tier should be kept as a unit. Deciding where to isolate an application
with a complex middle-tier object hierarchy is difficult, and upgrading only parts
of a complex middle tier typically necessitates numerous interoperability calls
between environments, resulting in performance degradation.
You should also consider the following issues when replacing the middle tier:
● To transparently replace middle-tier components with .NET components without
affecting client code, you must maintain the original GUIDS and ProgIDs of your
COM components. In addition, you must properly handle replacement of the
class interface generated by Visual Basic components when you attempt to
transparently replace a COM component.
● You will have to translate the ADO.NET datasets that are returned from your
upgraded middle-tier components to ADO recordsets that are used in your
original Visual Basic code.
Chapter 2: Practices for Successful Upgrades 39
● You will need to deploy the interoperability assemblies for the middle tier com-
ponents.
● Interoperability between Visual Basic .NET and Visual Basic 6.0 can become
prevalent in this type of upgrade, depending on how you choose to define the
application tiers. If the distance between the tiers is widened by making one side
of the communication a .NET assembly, you may be increasing the amount of
marshaling that is occurring in your application, which can negatively affect
performance.
After you decide on an upgrade strategy, you can increase the efficiency and chance
for success in the upgrade process by producing a project plan for the upgrade. For
more information, see the “Producing a Project Plan” section later in this chapter.
Testing
To make sure that your application achieves functional equivalence regardless of the
upgrade strategy you choose, you need to produce comprehensive unit and system
test plans for the entire system, as well as for individual upgrade modules and tiers.
For detailed information about testing in upgrade projects, see Chapter 21, “Testing
Upgraded Applications.”
Figure 2.2
Partial source metrics for a stock management application
The figure shows partial information about data types and controls occurrences, the
source code inventory (in the form of a tree view), and the location of specific uses of
data types; in this case the Integer and String types. The assessment tool provides
all this information in easy-to-read HTML reports. For more information about the
assessment tool, see Chapter 3, “Assessment and Analysis.”
● The upgrade wizard found language changes in the upgraded code and prompts
you to manually review them. An example of this is the case default properties in
Visual Basic 6.0. Whenever possible, the upgrade wizard will resolve default
properties and explicitly expand them in the upgraded code; however, you
should review these expansions to verify that the correct property was substi-
tuted for the default property in the original code.
A useful way to begin to analyze the upgrade issues in your application is to orga-
nize them into the following two categories:
● Not upgraded and unsupported issues. These issues indicate the presence of
unsupported features, the use of control properties or methods, or the existence
of statements that require manual intervention. All of the issues in this category
prevent successful compilation of the upgraded application. After unsupported
features are addressed, the vast majority — as much as 95 percent — of the
remaining issues in this category are resolved by using simple code analyses to
find solutions in Visual Basic .NET. For example, some classes and methods of the
COM+ interface, such as ObjectContext and Commit are not upgraded. Equiva-
lent members and functionality can be found in the .NET namespace
EnterpriseServices. The remaining 5 percent of the issues require either minor
changes in the application logic or in the implementation of supporting function-
ality.
42 Upgrading Visual Basic 6.0 Applications
● Different behavior issues. These issues indicate that the upgraded code might
have behavior that differs from the original behavior in the Visual Basic 6.0
application. With these issues, you should manually review the possible conse-
quences of the new behavior under the code context because you may need to
modify the code. Issues in this category do not prevent the upgraded application
from compiling successfully, but they may produce run-time errors and cause the
upgraded application to fail. Experience with this category of issues has shown
that only a few of them require manual intervention. Their descriptions can also
provide guidance during unit testing of the upgraded application by describing
the behavioral differences. By using this information, testers will know what
behavioral differences to expect and can test whether or not the differences break
the functional equivalence of the upgraded application. For this reason, you
should not remove them from the code until after application has been success-
fully unit-tested.
For each category, note the different issue numbers and the frequency of their
occurrence. Beginning with the most frequently occurring issues, determine the best
solution and the effort required to resolve them. Because these issues occur the most
frequently, you should work on them first. Next, determine solutions and effort
estimations for any remaining not upgraded or unsupported issues. Then, finish up
by determining the resolution and effort required for issues that relate to behavior
differences. Not upgraded and unsupported issues are usually more critical to
resolve than behavior-related issues. A practical way to estimate how much effort is
needed to resolve an issue is to perform a test run of the upgrade where many of the
issues can be resolved, and use data from this experience as a benchmark.
● Functional testing
As with any software development process, carefully plan and schedule so that you
can meet the milestones for each deliverable. This will help you to manage the
expectations of your internal and external customers. Also, be sure that when you
schedule your upgrade project, you consider the rest of the projects being conducted
within your company to ensure that your project has the IT support it needs.
Estimating Cost
Estimating the cost requirements for a software development project is typically a
complex task because of the wide range of quality in software implementation and
the varying programming abilities of developers. Estimating the cost requirements
for an upgrade project is no different. Many factors affect the amount of effort that
will be required to upgrade an application. Similarly, these factors affect the cost of
the application; therefore, estimations for cost will vary widely depending on the
application.
Some factors that affect cost estimations are common to all upgrade projects. These
common factors include:
● The methodology of the Visual Basic 6.0 code; whether the code was written in an
object-oriented fashion, the extent that it relies on a common set of services
shared across a family of applications, and the interdependencies between parts
of it that will be upgraded and parts that will remain in Visual Basic 6.0.
● The maintenance history of the original code. Applications with a history of
requiring frequent fixes are likely to require frequent fixes during the upgrade.
● The complexity of the application requirements.
● Security considerations.
Other factors that could affect your cost estimation are specific to the code and the
platform of the application. Factors such as the use of mechanisms and constructs
such as RDO/DAO data binding, late-bound objects and ActiveX documents affect
estimations of cost. For ASP code, factors include the use of render functions (as
opposed to Response.Write), the use of multiple languages per page, the use of
nested include files, reliance on 16-bit integer size, default parameters, and GOSUB,
among other specifics.
44 Upgrading Visual Basic 6.0 Applications
The following tasks will also affect the final estimations for the costs of your up-
grade project:
● Resolving unsupported features. It is necessary to estimate the costs for different
issues that affect unsupported features. These issues include:
● The research costs for alternative solutions.
phase can be skipped if your original tests cases are adequate and it is only neces-
sary to adapt them to the new platform. As for any development project, the execu-
tion of test cases must be done in an iterative way as you get closer to completing
the project.
Finally, estimating costs for the deployment phase of an upgrade project is compa-
rable to the deployment costs of traditional software development projects. Of
course, you need to train your team to understand and deal with the issues of .NET
deployment. The good news is that generally, .NET deployment consists of a much
more streamlined mechanism than COM-based applications.
Using the information in this section as a guide, you should be able to estimate costs
for the work-hours that are required for the upgrade project. After you complete the
first estimate, you can further refine the figures and make adjustments as necessary.
This process can also apply to the upgrade plan. When you estimate project costs in
this way, you will notice that the main difference in expenditures for a traditional
software development project and those for an upgrade project involve the testing
phase. The testing process for a traditional project represents approximately 20
percent to 30 percent of the total cost. The testing process for an upgrade project can
easily represent 60 percent to 70 percent of the total cost. However, the overall work-
hours required for an upgrade project are considerably fewer than those required for
a traditional software development project.
Upgrade tests performed by Microsoft and its partners found that when code is
adequately prepared prior to the upgrade, the cost of upgrading from Visual Basic
6.0 to Visual Basic .NET is typically 15 percent to 25 percent of the total development
cost. This figure takes into account the learning curve of Visual Basic developers
who move from Visual Basic 6.0 to Visual Basic .NET. The next section investigates
how to best prepare your application for the upgrade.
may seem like additional work, but in the end, these early modifications will save a
great deal of work.
Before preparing the source code for the upgrade, it is important to first prepare the
development environment that you will use to upgrade the application.
The code advisor must be downloaded and installed on your computer before you
can use it. It is not installed automatically with Visual Studio 6.0. For more informa-
tion about the code advisor, see Chapter 5, “The Visual Basic Upgrade Process.”
For more information about the upgrade wizard, see Chapter 5, “The Visual Basic
Upgrade Process.”
For more information about how to prepare your code for the upgrade, see Chapter
5, “The Visual Basic Upgrade Process.”
Code Advisor
Report
Modify
Upgrade
Report
No Ready for
Upgrade
Yes
Figure 2.3
A graphical representation of the code preparation phase
VBX controls will not be automatically converted. You will also have to replace
Win16 Windows APIs with their Win32® counterparts.
Visual Basic versions 2.0 and 3.0 often require an extra step. Visual Basic 6.0 can only
open files in text format, whereas Visual Basic versions 2.0 and 3.0 support two file
formats: binary and text. Before upgrading these projects, ensure the entire applica-
tion is saved in text format by using the following procedure.
To convert Visual Basic 1.0 and 2.0 files to text format
1. On the File menu, click Save As.
2. In the Save dialog box, select the Save As Text check box.
Because Visual Basic 1.0 can only save files in binary format, all of these projects will
first need to be opened in Visual Basic 2.0 or 3.0 and then saved as text before they
can be converted to Visual Basic 6.0. After converting the project to Visual Basic 6.0,
you can begin the process of upgrading it to Visual Basic .NET.
Verifying Compilation
The upgrade wizard is designed to work with valid Visual Basic projects, so it is
very important to verify that the code is syntactically correct before trying to up-
grade it. If files have errors the upgrade wizard might have problems when it is
trying to parse the code and you may get some misleading error messages or, worse,
unexpected results. Correct syntax can be verified by compiling the Visual Basic 6.0
project before applying the upgrade wizard.
This also helps you ensure that all the necessary source code is available. The up-
grade wizard first analyzes all the code, and then uses the information it obtains to
make decisions. It then starts the conversion of the code. If there are missing files,
some of the decisions that the upgrade wizard makes may prove to be incorrect.
Compiling the original source base in Visual Basic 6.0 before applying the upgrade
wizard will help ensure that the tool will have all the information it needs to make
the best choices possible. The better the decisions the upgrade wizard makes, the
less manual intervention will be required to achieve functional equivalence.
the upgraded application. At this point, the generated code is referred to as green
code because it is fresh out of the upgrade wizard and has not yet been manually
modified.
In the second step, you modify the green code so that it will compile and replace all
remaining code that was not completely upgraded with valid Visual Basic .NET
equivalents. Samples of the kinds of modifications that are necessary are listed in the
“Preparing to Handle Upgrade Issues” section earlier in this chapter.
For more information about these two steps, see Chapter 5, “The Visual Basic Up-
grade Process.”
After the application successfully compiles and all issues that were reported by the
upgrade wizard have been addressed, you are ready to begin testing. Testing is
discussed in the following section.
Deployment
After you have upgraded and tested your Visual Basic .NET application, it is time to
start the deployment of the completed application. The main objective of deploying
.NET applications is the same as deploying Visual Basic 6.0 applications: you need to
install your application and get it running on the client’s computer or on the produc-
tion servers. However, the way you do this, the dependencies that your application
has, and the mechanisms for handling updates and security have all changed. The
Chapter 2: Practices for Successful Upgrades 53
reason for this is the .NET assembly — the new packaging mechanism for .NET
applications.
The primary new dependency that you will have to confirm when deploying your
.NET application is whether the .NET Framework is installed on the target comput-
ers. If there is a chance that the .NET Framework is not installed on the target
computers, you should consider providing a way for your users to install it.
Assemblies
The smallest deployable unit of a .NET application is called an assembly. An assem-
bly is a collection of classes, configuration files, resource files, and any other files
that your application needs at run time. An assembly can be an executable (EXE) or
a dynamically linked library (DLL).
What makes an assembly different from previous types of executable files and DLLs
is that the assembly contains extra information, called metadata, about itself and
about the classes it contains. Among other things, the extra information that an
assembly contains helps distinguish different versions of the same assembly.
The assembly also contains security related information that can ensure that the
assembly comes from who you think it comes from and that it has not been modified
since the original creator released it.
Versioning
You can easily install multiple versions of the same assembly in the global assembly
cache and the global assembly cache will maintain these assemblies separately.
These versions can have the same name and the same GUID (for exposure to COM)
but have different versions. The .NET Framework will ensure that only the version
of the assembly that your application was compiled against will be linked to it at
run time. For you to change the version of a DLL that an application uses without
reinstalling the application, you need to insert special directives into the configura-
tion file for that application. This installs an incompatible version of a DLL, thereby
54 Upgrading Visual Basic 6.0 Applications
Side-by-Side Execution
The benefit of allowing different versions of the same assembly to be installed on
the same computer and shared by different applications is that you can now easily
install multiple versions of your .NET applications on the same computer and allow
them to run side by side without interfering with each other.
Configuration
Deployment and side-by-side execution are also facilitated by the fact that .NET
applications do not need to keep any configuration information in the Windows
registry. This eliminates the registry as a source of collisions between different
versions of an application.
Configuration information for .NET applications is kept in XML-based configuration
files in the same directory as the application itself. Another file exists that applies to
all the versions of the same application, while a third exists at the computer level.
Update Deployment
As previously mentioned, an installed application will only normally link to the
same version assembly that it was compiled against. However, it is possible to add a
configuration setting to the application’s configuration file to tell it to stop using the
version of a DLL that it was installed with and to start using an updated DLL. This
redirection can only occur with explicit redirection. This makes it easy to modify
installed applications with service packs or application updates. In this situation,
deleting the old DLL and installing a new version is not enough; this will simply
stop the application from running.
computer before the installation will continue. In addition, you can add your own
custom installation actions and application specific dialog boxes to the installation
process.
The setup projects offered by Visual Studio .NET are usually built to create Windows
Installer files (.msi) that can be stored and distributed on a CD, on a Web site, or on a
shared network directory for installation across a network.
Visual Studio .NET provides the following deployment projects for installing differ-
ent types of applications:
● Setup project. This is a generic Windows application setup project that you can
add arbitrary files and actions to.
● Web Setup project. This kind of project is intended for installing Web applica-
tions and can automatically handle issues with registration and configuration.
● Merge Module project. This type of project is used for deploying shared compo-
nents by incorporating them into other installation projects.
● Setup Wizard. This is not a type of project, but a wizard that helps you build an
initial setup project from existing Visual Studio .NET application projects. These
projects can be customized later.
● Cab project. A Cab project allows you to assemble a collection of files and project
outputs for compression and for copying onto other computers. This type of
project is commonly used for packaging ActiveX controls.
Advancing an Application
After testing is complete, you should have a working application that is functionally
equivalent to your original Visual Basic 6.0 application. In many cases, the reason for
upgrading an application in the first place was to add new features to it. After you
have functional equivalence, you can begin application advancement to achieve the
results you envisioned. All new development will be done in Visual Basic .NET.
Application advancement is the improvement of the upgraded application beyond
the specifications of the original application. It often includes adding features that
are easier to implement in Visual Basic .NET than they were in earlier versions of
Visual Basic. For some features, such as threading, it may be the first time it is
possible to implement the feature in your application.
For detailed information about application advancement, see Chapters 17, “Intro-
duction to Application Advancement,” Chapter 18, “Advancements for Common
Scenarios,” Chapter 19, “Advancements for Common Web Scenarios,” and Chapter
20, “Common Technology Scenario Advancements.”
56 Upgrading Visual Basic 6.0 Applications
Change Management
You will find that source management issues are more complicated during an
upgrade project than they are during typical application development projects. If
you do not have a source control system you should consider purchasing one; it will
save a lot of headaches caused by multiple programmers working on the same set of
files and overwriting each other’s work.
● Version history. As files are changed and the application progresses, source
control systems keep histories of the files that allow you to see how the applica-
tion looked at any point in time. This feature makes source control systems useful
even for single developers who need to keep track of previous versions of their
source code. For example, in most systems you can label versions of source files
so that you can easily extract a version of the source control that matches the
version that a particular customer has. With the exact version you can more easily
reproduce bugs.
● Source branching. Most source control systems allow you to have multiple
branches in your source tree where different teams of programmers are working
on different versions of the application simultaneously. Usually, at some point,
the different versions are merged into a single branch again. For example, in the
case of the customer who has a bug in their version of the application, you may
need to replace the application with a more current version. However if you have
continued to develop the application and it is not yet stable or you do not want to
give them new features that are in the current version, you can branch the code at
the version of the source that they have and fix the bug within their version. The
resolution of this bug can then be merged back into the main source branch later.
Some of the advantages of using a source control system are:
● You minimize lost work due to programmers overwriting each other’s work.
● You always know who is working on each source file and can coordinate multiple
changes to those files.
● You simplify the coordination of multiple programmers working on the same
application.
● You always have access to any previous version of your application.
● You have a controlled way to release a single programmer’s source file changes to
the rest of the development team.
Source Branches
As previously discussed, many source control systems will allow you to create
independent branches in your source code where there are multiple versions of your
application being developed independently. Depending on the source management
policies of your office, you will probably use several different source branches
during the upgrade project. The following source branches may be included:
● Original source branch. The original source code will usually have its own
branch. If there is any chance that you will need to continue development of the
original Visual Basic 6.0 application, you should leave the original version of the
application in its own branch and create a new branch for the upgrade.
● Code preparation branch. As previously discussed, code preparation involves
modifying the original Visual Basic 6.0 source code to prepare it for use with the
upgrade wizard. Although the application remains a valid Visual Basic 6.0
application, the modifications involve changes to the source code that can intro-
duce bugs.
Some development centers have strict restrictions about changes made to the
source code and rules about how those changes are tested and even checked in.
For example, it is common for many companies to insist on an initial set of tests
before files are even checked in; these are referred to as check-in tests.
In these cases it is useful to create a source branch especially for the code prepara-
tion. In this way all of the changes that you make to the original application are
kept separate from the main branch of development and the original application
can continue to evolve.
● Green code and functional equivalence branch. After the code is prepared
you will pass it through the upgrade wizard and a new Visual Studio .NET
solution will be created. As previously explained, this new solution is referred to
as green code.
The green code is a brand new version of your application, independent of the
source code branches that contain the original and the prepared code source trees.
When you are happy with the output of the upgrade wizard, all further develop-
ment will apply to the green code.
Chapter 2: Practices for Successful Upgrades 59
Instead of using a new branch from the original application, it is common to create
a brand new source tree. This new source tree will be used as the basis for the next
step in the upgrade process: compilation.
In fact, after the upgrade wizard has generated the source tree, the green code is
typically used for the remaining steps of the upgrade. The first step is to achieve
functional equivalence with the original Visual Basic 6.0 application and the second
step is application advancement that involves adding new features and improving
existing functionality. All of this work is serial and can be performed on the same
source tree just as with any other development process.
At times, you may want to create reports of the changes that were made to the green
code. As previously mentioned, your source control systems provide a mechanism
to generate a copy of the original green code files and a copy of the source code at
any point. With these reports, you can determine the exact changes made to the
source code by comparing the files of the green code versions to the functionally
equivalent version.
● Minimize the effort that is required to achieve functional equivalence for your
application.
references are also compiling. If you have multiple developers working on separate
files you will find that they all will have dependencies on common files and they
will have to wait while one person fixes the file they all need.
The obvious way to minimize occurrences of this scenario is to determine the files
that have the fewest number of dependencies on other files and to start correcting
those. Another characteristic to consider is how many other files depend on the files
that you start working with. The files that are most important to start with are those
that depend on no other files but have many dependants. This way when the file
does compile you enable the compilation of as many other files as possible at the
same time.
The assessment tool provides a lot of valuable information and even suggests the
order that files should be handled during compilation. For more information about
the assessment tool, see Chapter 5, “The Visual Basic Upgrade Process.”
As developers resolve local issues and check in their files, other developers should
perform additional searches for local issues in their own files. Often a change in one
file will fix the problem in another file, effectively converting what was once a global
issue into a local issue.
With this approach, you will gradually move your files into a state where they will
compile successfully. This process will be easier if the files have as few external
dependencies as possible
After all of the files are able to compile, there are usually remaining issues that
concern missing functionality that need to be resolved. Either code was commented
out, or green code was marked as code that potentially behaves differently. These
issues usually result in a list of tasks in the Visual Studio .NET Tasks window and a
list of EWIs and other code that was commented out while making the files compile.
You can continue to delegate work based on project or source code files. Alterna-
tively, it may now make sense to delegate work based on EWIs or tasks. You can
assign specific EWIs to developers or you can assign them selected lists of tasks. You
may want to do this when some issues need specialized knowledge and it makes
sense to assign them to appropriately capable developers. The advantage of this is
that it allows your developers to specialize in certain aspects of Visual Basic .NET to
speed up progress on the project.
The following common tasks can be assigned to developers instead of assigning
them files to compile:
● Typing variables that have no type or are typed as objects. The upgrade wizard
that ships with Visual Studio .NET does not attempt to induce the type for
variables that are not typed explicitly or are assigned some generic type. (The
ArtinSoft Visual Basic Upgrade Wizard Companion will do this. For more infor-
mation about the upgrade companion, see Chapter 5, “The Visual Basic Upgrade
Process.”) This leads to variables that have inappropriate types and the inability
to recognize the use of default properties. An important task that needs to be
done is to find variables in each file whose types have been upgraded to Object
and assign them a more suitable type.
● Manually fixing code that did not convert correctly. Typically, functionality that
was not upgraded correctly by the upgrade wizard in one file also appears in
other files in your application. An API such as the printing API, and the use of the
Windows Forms collection that has no direct equivalent in Visual Basic .NET, are
examples of functionality that can not be upgraded and will appear in multiple
files in your application. To fix these problems, you can assign developers specific
APIs and have them review and upgrade the uses of those API’s in your applica-
tion.
● Testing ActiveX/OCX components. Many ActiveX and OCX components will
work with the wrappers that are generated by the upgrade wizard however,
some will not. It is useful to know the ones that will not work at the outset of
your upgrade project. Before you start your upgrade project, determine the
Active X and OCX components that will not work in the .NET environment. You
should do this outside the application’s context to simplify the fixing of bugs in
the component. This ensures that any problems are a result of incompatibility
between the component and the wrapper, or between the component and the
.NET Framework, and not because of issues within the upgraded application.
Chapter 2: Practices for Successful Upgrades 63
DLL, you will have a much easier process. In this case you simply create a new .NET
project that will eventually replace your old DLL. Whether or not you are using a
source control system, it is a simple process because you create the new DLL inde-
pendently of the current DLL and start using the new DLL when it is ready.
The second approach involves replacing the user of a component, such as a COM
object or DLL, with a .NET equivalent. The development of the client is independent
of the original client and the new client is used when it is ready. If you can avoid
changing the shared component, the process is much easier. If the component must
be changed, try to make the change to the original project before starting the up-
grade instead of during code preparation.
These are all micro issues. Micro issues are commonly-occurring, easy-to-fix prob-
lems. From these projects, 41 percent of the issues occur in the design of forms, 59
percent of the issues occur in modules, classes, code-behind-forms, and other project
items. On average, modules, classes and code-behind-forms have one upgrade issue
for every 106 lines of code; forms have one upgrade issue for every five controls.
66 Upgrading Visual Basic 6.0 Applications
● When solving a problem during the upgrade, keep in mind that you want to
preserve the functionality, not the code. Sometimes it is better to replace an entire
piece of code with functionality that is provided by the new platform than to try
to re-implement the old features in the new platform just to keep things exactly
as they were in the original application.
● Divide the testing phases into partial testing and full testing. Partial testing can
be understood as code and unit testing; it is focused on isolatable pieces of the
application such as components, classes, a particular method, and so on. Full
testing — also referred to as system testing — comprises the testing of the func-
tionality of individual components, the functionality of the entire application,
and the application’s integration with other applications. Partial testing will find
errors before you integrate the entire system. It is not unusual to find bugs in the
upgraded application that also exist in the original application but that have not
yet been detected. Differences in the execution of the applications in the two
environments can identify such errors. Resolving these bugs may be simpler
when they are found during unit (localized) testing instead of during full system
testing.
● Test cases are a great measurement tool for quantifying the progress of the up-
grade process. They also confirm when the application reaches functional equiva-
lence. As with any software project, test cases help to maintain a high level of
quality in your application.
● Dedicate resources to testing. If you do not have dedicated testers, assign one set
of developers to perform the upgrade and a different set of developers to test the
upgraded code. This will improve the effectiveness of bug detection. Assign team
members who know the business perhaps better than they know the code to
testing.
Summary
Deciding whether reaching functional equivalence is sufficient or if you need to add
new features to an application is an important decision that you should consider
before you begin an upgrade project. Although you can start by first achieving
functional equivalence before adding new features, you should plan ahead for
future advancements so that any necessary hooks can be included during the up-
grade to facilitate future development work.
Understanding the different upgrade strategies and when each should be applied is
important so that you can make decisions, plan the upgrade, and the associated
estimate costs and effort. Should you upgrade your entire application, or only parts
of it (leaving parts in Visual Basic 6.0, which will require the use of interoperability
techniques)? Should you perform the upgrade all at once, or do it stages one compo-
nent at a time? These are questions you will have to answer before you can even
begin upgrading.
Finally, a successful and efficient upgrade project relies on a methodical approach
with clearly defined stages. The process outlined in this chapter provides you with
the knowledge you need to prepare and to carry out realistic upgrade project plans.
More Information
For more information about Visual Studio, see the Microsoft Visual Studio
Developer Center on MSDN:
http://msdn.microsoft.com/vstudio/.
3
Assessment and Analysis
Introduction
Assessment and analysis usually means two things: determining how best to up-
grade your applications to the Microsoft .NET Framework and how much it will
cost to do this. This chapter discusses the best ways to gather this information.
The “Evaluating Upgrade Objectives” section discusses many of the common
expectations that come with an upgrade to Microsoft Visual Basic .NET and dis-
cusses the realities behind those expectations.
The “Gathering Data” section provides information about what you should have
ready to help you make important decisions for the upgrade process and how best
to gather that information.
The “Application Analysis” section examines the Visual Basic 6.0 Upgrade Assess-
ment Tool (included with this guide) and how to use it to get statistical, structural,
and functional information from your applications. You will also learn how to use
this information to help you make decisions about the best way to upgrade your
applications.
The “Estimating Effort and Cost” section explains how to estimate the time and cost
of your upgrade project.
Each section describes how to collect the information you need and the value of this
information to the project. You will see how best to use the information to reduce
costs and risks and to increase your return on investment (ROI).
To best determine the strategy and cost for upgrading your application, you need to
ensure your scope and plan your project appropriately, and then test the upgraded
application fully after it is a .NET Framework application. You have to be aware of
70 Upgrading Visual Basic 6.0 Applications
all the assumptions you are making and the expectations you have and to ensure
that they are all correct. This chapter helps you learn how to do so.
Typically, the older a feature is, the more likely it is that it depends on some behav-
ior of an earlier version of Visual Basic that is no longer supported in Visual Basic
.NET — a behavior that would be difficult to upgrade to Visual Basic .NET.
There are several analysis techniques that you can use to determine the features that
are no longer used and can be left out of the upgrade. Use case analysis and input/
output analysis are two such techniques that are discussed later in this chapter.
Planning
To create an effective project plan, you have to know exactly what has to be done,
who is available to do it, and how long it will take. Some of this was described in the
“Project Scope and Priorities” section earlier in this chapter. The following sections
discuss some other considerations that you should keep in mind during planning
and that can be clarified with careful application of the Visual Basic 6.0 Upgrade
Assessment Tool (hereafter referred to as the “assessment tool”).
a weight that affects other elements of the estimation. For more information, see
“Estimating Time and Cost” later in this chapter.
For example, the number of lines of code affects the amount of time required to
create an inventory of the application, define the order of the upgrade, review the
upgrade report generated by the first run of the Visual Basic Upgrade Wizard, and
so on.
The assessment tool reports how many lines of code there is in the application and
in each of the files and components that comprise the application.
The MainReport.xls file also provides a fairly complete set of information about the
kinds of tasks that need to be completed to upgrade your project. Furthermore, it
hints at the resource categories needed to complete those tasks.
For example, each error, warning, or issue (EWI) that is found by the upgrade
wizard has an associated suggested resource, such as developer or architect, that
implies a minimum level of experience for the individual that is responsible for
resolving that EWI. These are default suggestions provided by the assessment tool,
but these can be adjusted in the Config – EWI tab if you disagree with any of the
suggestions.
Also, all the different features of Visual Basic 6.0 code that require manual upgrad-
ing have associated with them suggested resources in the Config – General tab of
the MainReport.xls. These values can also be adjusted, which allows you to select
your own resource if you disagree with the suggestion.
The suggestions made for the type of resource required to deal with the various
upgrade tasks are based on experience with numerous Visual Basic 6.0 upgrade
tasks. However, your situations may vary depending on the resources available in
your company. The configurability of the reports allows you to adjust them to suit
your environment.
● Effort – EWI: This tab summarizes the effort estimate for each EWI.
Each of these tabs is discussed in more detail in the “Estimating Effort and Cost”
section later in this chapter.
The estimates shown in these tabs are based on configurable values found in other
tabs. As mentioned in the previous section (“Assessing the Necessary Technical
74 Upgrading Visual Basic 6.0 Applications
Expertise”), you can use the Config – Resources tab to adjust the cost for each type
of resource. The values you supply will automatically be used in the effort reports.
The Config – EWI and Config – General tabs suggest the type of resource and the
length of time required to perform various upgrade tasks. These values can also be
modified to suit your needs, and any changes you make will be reflected in the
effort reports that depend on them. Thus, the task of estimating cost and effort for
your upgrade project is simplified because you need only specify modifications in
the configuration tabs and all effort reports are automatically adjusted to reflect your
modifications.
The configurability of the various estimates in the MainReport.xls file will help your
organization improve their accuracy over time. The more upgrade projects your
developers participate in, the more information you gather about the costs and effort
required to handle different aspects of upgrading. This information can then be used
to adjust cost and effort estimates in the assessment tool reports in future projects.
Defining Priorities
Another important goal of the type of application analysis is defining upgrade
project priorities. This is important because it helps focus effort and direct decisions.
Priorities depend on the business and technical objectives at the root of the upgrade
project, but to some degree, it also depends on the result of the analysis of the
content, the operation of the application, and on the time and budget available.
Depending on the content of the application, priorities might include risk manage-
ment by requiring a pilot project or initial testing of certain parts of the application.
One example scenario is where new business requirements include specific increases
in performance or scalability to a handle a larger user base. This requires a close
analysis of the current architecture and bottlenecks and a good understanding of the
features of Visual Basic .NET that can increase performance and scalability. Chapters
1 and 14 discuss some of these features. Prioritizing bottlenecks helps to speed the
upgrade.
Another example scenario is the addition of a new Web service interface in as little
time as possible. If interoperability is an acceptable solution, a partial upgrade may
be all that is necessary because you only need those components that provide
content to the Web service; the other components can remain in Visual Basic 6.0.
Here, prioritizing only the additional service would achieve the most efficient
solution in terms of time and cost.
One final example is a scenario where the priority is consolidation. In this case, a
partial upgrade is not an option and focus must be placed early in the project on
those components that are more difficult to upgrade because they are the potential
show-stoppers.
Chapter 3: Assessment and Analysis 75
Business Objectives
Upgrade projects will have an impact on business objectives of your company. This
section addresses some of the key considerations and expectations of an upgrade
project from the perspective of business objectives.
After assessment, you may determine that certain features are no longer needed or
used. This is a good opportunity to reduce upgrade time and clean up the new
application by removing code and features that are no longer used. However, you
have to be careful when making decisions like this because other features may have
undocumented dependencies on the features you remove. Also, you may find that
some users do in fact use those features although they did not report that they use
them or they use them for reasons other than those for which they were originally
intended. For example, it is common to read information from reports that is actu-
ally secondary to the prime intent of the report simply because this report is easier
or faster to create than the one that should be used.
Other changes that can cause disruption come from the fact that any procedures you
had in place for testing and deployment will likely have to change. Because the
application is no longer based on Visual Basic 6.0, you may have to modify your
testing procedures, especially if they were automated. Also, deployment require-
ments will change, so you must also update your deployment procedures.
Finally, although the new application will contain most of the business logic from
your original application, this does not mean that your programmers have nothing
new to learn. Visual Basic .NET is a new language. It has new syntax rules, a new
API, supports a new programming methodology, and no longer supports many
common practices of Visual Basic 6.0 programmers. Upgrading your original appli-
cation is a great way for them to learn this new language, but they will need some
level of familiarity with Visual Basic .NET before the upgrade begins.
Reducing Risk
If the earlier application is working well and is fulfilling user and business needs, a
common expectation is that a direct upgrade to the new platform involves far less
risk — it is simply the identical business logic moved to a new platform.
Legacy code has often been facetiously defined as “code that works.” It has been
used, tested, and improved over a long period of time. If it works, there is no need
to rewrite it. Writing new code also implies creating new bugs that must be found
and fixed. Because much of the original code is automatically upgraded, you do not
Chapter 3: Assessment and Analysis 77
need to write as much new code as you would if you rewrote the application from
the beginning. This results in less risk of introducing new bugs to the application.
developers more difficult and maintaining your application more and more expen-
sive. Also, many businesses have made significant investments in training their
people and want to know that their skills are current. If they still need to go outside
the company for expertise, they also want to know that there is a ready pool of labor
that they can choose from. Otherwise, in time, the ROI from an upgrade will come
from the fact that it is simply more expensive to not upgrade.
Technical Objectives
Any upgrade project will have technical objectives behind it. This section discusses
some of the common technical objectives for performing an upgrade.
Chapter 3: Assessment and Analysis 79
Ease of Deployment
Also of importance to IT is deploying an application across an entire organization.
Applications with sophisticated deployment schemes can be costly to install among
multiple computers. DLL versioning conflicts result in lost productivity for users
and costly trouble-shooting for IT personnel.
The .NET Framework provides application deployment options that simplify the
process of deploying applications. It also provides options to help in protecting
against version conflicts, thus ensuring that deploying a new application will not
break currently installed applications.
Chapter 3: Assessment and Analysis 81
For more information about deployment options, see the “Upgrading Application
Setup” section in Chapter 16, “Application Completion.”
Gathering Data
As mentioned at the beginning of the chapter, our goal is to determine how best to
upgrade your applications to Visual Basic .NET and how much it will cost to do so.
With this in mind, this section examines two ways to view your applications and
extract information about them to help with your upgrade decisions.
The first way to view the application is based on how it is used. In this case, you will
have to look at the environment in which the application executes, who the users are
and how they use the application, and what features the users actually use. When
looking at your application from this perspective, remember that users in this
context can be human end users or other systems that interact with your applica-
tions. This technique for analyzing the application is especially useful if you have
reason to believe that your application contains a lot of features that were created
long ago but are no longer needed.
The second way to view the application is to analyze its content. This includes the
features that it offers, the technologies that it uses to provide those features, the code
that was written to manipulate the technologies, and the interactions between all
these pieces. Therefore, you are interested in the source code that was used to build
the application, its size, complexity, and the third-party libraries it references. Also
of interest is how the applications are structured, what subsystems the design
highlights, what dependencies the applications have on external systems, and the
mechanisms used by these subsystems and external systems to interact with each
other. The assessment tool included with this guide is a great way to start this kind
of analysis.
The following subsections examine the techniques for analyzing your application’s
usage and how the assessment tool helps catalog the elements of your application.
set of use cases can be used to define the set of functionality that needs to be up-
graded to Visual Basic .NET. If your application already has use cases, you can use
them as a starting point. Just keep in mind that new usage scenarios may have been
added since the original use cases were created because use cases are usually created
before any application development even begins.
Examples of Use Cases
A use case usually consists of text describing a set of steps that lead to the comple-
tion of a specific task. For example, it can describe the steps a user would be ex-
pected to execute to process a check received from a client.
A typical use case contains information such as the following:
● Name. This identifies the use case.
● Pre-conditions. These indicate assumptions about what should be true before the
steps in the use case are executed.
● Steps. These are the steps that are required to execute the use case.
● Post-conditions. These indicate the conditions that should exist after successful
completion of the steps of the use case.
● Actors. This indicates who would normally execute these steps.
● Scope the use case properly. Make sure the scope of the use case is clear. This can
be done by including triggers and expected results with each use case. A trigger is
some event that usually requires or causes the initiation of the use case. Expected
results are the direct consequences of the use case.
● If you are using use cases that were created for the original application require-
ments, confirm that the use case covers a scenario that is still valid and useful.
Some older use cases may describe tasks that are no longer needed or have
changed since their original conception.
● Involve the users in the development of these use cases. In the end, it is the user’s
requirements that are reflected in the use cases, and they should be involved in
creating and verifying use cases.
Creating New Use Cases
Ideally, you should already have use cases from when the original application was
being designed. If there are no such use cases available, here are some ideas for how
to create use cases now:
● Interview current users of the application.
Inputs/Outputs Analysis
A classic way to describe computer software is by means of cataloging the full set of
data that it receives and the full set of data that it produces. This technique is a
simple but effective way of creating a formal specification for the behavior and the
usefulness of an application.
This guide does not document the implementation of the pieces of the application,
and it documents protocols, formats, the user interface, and other forms of interac-
tion with the application only in relation to the input or output being described. For
example, the user interface screen that a user interacts with to add client information
to your application is described in terms of its content instead of its layout.
84 Upgrading Visual Basic 6.0 Applications
Examples of Inputs
Inputs are anything that is entered into the application by an employee, a client, or a
user of any other kind, or an external application. Examples of inputs include:
● Raw data manually entered by a user to a data entry screen of the application,
such as customer information.
● Any documents built externally to the application and sent to the application,
such as e-mail messages, reports, lists, or raw data.
● Asynchronous messages received from other applications.
Examples of Outputs
Outputs are anything that the application produces, displays on the screen, prints,
sends to other applications, or stores on some storage device such as a hard disk,
floppy disks, CDs, tapes, or the network. Examples of outputs include:
● Reports that contain raw or summary information based on existing data and
usually in response to some query or as a result of a scheduled event.
● E-mail messages, faxes, or other electronically transported documents.
● Graphs, text, bar charts, graphics, sound, and other representations of data.
● Events, alerts, and other messages that are transparently logged or require
immediate attention.
Application Environment
The environments in which the applications are developed and deployed both play
an important role in helping define priorities and avenues of investigation when
issues need to be resolved.
For example, if you are not a part of the original development team, it is important
to know who is responsible for the original development, architecture, design,
Chapter 3: Assessment and Analysis 85
Application Analysis
Determining and understanding the effort required to execute an upgrade project is
a complex task that requires the support of different tools. This process involves the
division of the entire application into smaller, more manageable pieces that can be
independently counted, understood, and estimated. As a consequence, upgrade
effort estimation is an analytical process that can be supported at different stages by
automated tools.
The original application analysis is an essential part of an upgrade project. It pro-
vides a better understanding of the application to be upgraded and produces infor-
mation necessary for planning and decision making. The assessment tool will
generate all that information in addition to information that is useful for the execu-
tion of the upgrade, such as the Recommended Upgrade Order report.
The Visual Basic 6.0 Upgrade Assessment Tool works as a measuring instrument for
an application upgrade effort. This tool analyzes the application components and
the relationships between them from an upgrade perspective, which considers
elements, constructs, and features that consume significant resources during an
upgrade project.
The main goal of the assessment tool is to analyze Visual Basic 6.0 projects and
obtain information useful for planning the upgrade to Visual Basic .NET and for
estimating the cost of the upgrade. This tool will generate a group of reports that are
used as a basis for further calculations related to task effort and cost. The assessment
tool user can specify configuration values that will override the initial estimation
inputs; in this way, the assessment tool can be adapted to specific organizations.
The assessment tool analyzes the original application using a Visual Basic 6.0 parser
that takes into account all the projects specified by the user. The obtained data is
then processed to identify usage patterns and features that are difficult to upgrade.
After all these features are classified and counted, a series of reports with detailed
and summarized data is generated.
86 Upgrading Visual Basic 6.0 Applications
It is important to take into consideration that the assessment tool considers a high
percentage of the known upgrade issues that can arise when upgrading a Visual
Basic 6.0 application with the upgrade wizard; nonetheless, there are issues that are
detected only after the full automated upgrade. The detection of these issues re-
quires complex pattern recognition rules that are available only in the upgrade
wizard. These issues can be estimated as a percentage of the rest of the issues, as is
done by the assessment tool in the Upgrade Issues report.
The following sections explain the reports produced by the assessment tool and the
aspects that are considered in the effort estimation.
Figure 3.1
MainReport.xls Main Page
From the page illustrated in Figure 3.2, you can access the rest of the report in an
ordered fashion.
The first thing to notice is that this report contains a link to the second report, which
is in a file named DetailedReport.xls. To allow you to keep changes that you make to
the cost and effort configuration between uses of the assessment tool, you can re-link
the main report to any other detailed report from any other assessment. All of the
application specific data in the main report is linked to the specified detailed report.
The following sections discuss the different sheets that exist in these two reports.
Chapter 3: Assessment and Analysis 87
In general, the MainReport.xls file contains all the configuration settings, all the
estimates of cost, and summaries of the estimates of effort. The DetailedReport.xls
file contains detailed reports about the content of the application. The first page of
the DetailedReport.xls file is illustrated in Figure 3.2.
Figure 3.2
DetailedReport.xls Main Page
the upgrade strategy you choose; it can be a horizontal or vertical strategy, as ex-
plained in Chapter 2, “Practices for Successful Upgrades.”
Most of the application component relationships will remain in the target applica-
tion and the application’s general architecture according to the application type
equivalencies presented in Chapter 4, “Common Application Types.” Project type
changes or re-architecture tasks are not considered in this analysis for effort estima-
tion because these are deemed to be post-upgrade tasks after the functional equiva-
lence is achieved.
Inventory to Upgrade
The first aspect to be considered in the application analysis is the inventory of
resources and components involved in the upgrade process, which includes mod-
ules, third-party components, and intrinsic components. Some of these components
are user-defined, and their implementation needs to be upgraded In addition to the
source code that uses them. For third-party and intrinsic components it is necessary
to upgrade the code that accesses the corresponding component; in this case, for
assessment purposes, it is relevant to make an inventory of the class members and
other elements that are used in the application.
The table illustrated in Figure 3.3 is from the DetailedReport.xls file and shows an
example of the Project Files Overview report that is generated by the assessment
tool.
Figure 3.3
Project Files Overview report
This report presents the projects that were processed by the assessment tool and the
quantity of the different types of modules included in each project. This report can
be useful to identify projects with different types of functionality; for example,
projects that provide user interface elements (with a high percentage of form mod-
ules) or projects that implement the business logic functionality (with a high per-
centage of classes and modules).
User components account for a significant percentage of the upgrade effort; as a
consequence, the inventory of user component definitions and instances declared
must be taken into consideration when determining the inventory of resources to
upgrade. Figure 3.4 illustrates the DetailedReport.xls file and shows an example of
the User Components Summary report.
Chapter 3: Assessment and Analysis 89
Figure 3.4
User Components Summary report
The User Components Summary report considers all user-defined components and
the lines of code (LOC) contained in each of them. This report also presents the
quantity of instances of each class that are declared in the rest of the user code. The
estimation worksheet generated by the assessment tool also includes a detailed
report of the user components that provides the member usage for each component.
Third-party and Visual Basic 6.0 intrinsic components are also considered in the
application inventory to be upgraded. The upgrade of these components involves
the processing of the application source code to identify accesses to each of the
component members. All member usages will be analyzed to determine if there is an
equivalent member in the target environment; some of these members will not have
an equivalent in Visual Basic .NET and will require additional manual work to be
upgraded to .NET. Figure 3.5 illustrates the Third Party Component Summary
report from the DetailedReport.xls file; it includes all the components used in the
application and the quantity of instances that are created for each class.
Figure 3.5
Third Party Components Summary report
Visual Basic 6.0 intrinsic components are treated in a similar way to third-party
components, with the exception that most of the intrinsic components have an
equivalent in the .NET Framework and most of the member accesses require some
90 Upgrading Visual Basic 6.0 Applications
Application Resource Inventory and the Migration Order Definition; both of these
are estimated in the Effort – Total report generated by the assessment tool.
The assessment tool helps to capture source code metrics by producing a report of
the number of lines of code in a project. Figure 3.6 shows an example of the lines of
code (LOC) report in the DetailedReport.xls file produced by the assessment tool.
Figure 3.6
Lines of code (LOC) report
Source code lines are classified by the assessment tool as a result of analyzing all the
content of the application modules. Each line is parsed and classified to determine
how many visual lines, code lines, and comment lines are written in the Visual Basic
6.0 projects processed. Visual lines are lines that were generated by Visual Studio.
Figure 3.7
Upgrade Issues tab
The Effort – EWIs tab of the MainReport.xls file generated by the assessment tool
reports all the detected issues and the corresponding quantity of occurrences, their
complexities, and cost estimation values. It is important to take into consideration
that the assessment tool does not detect all possible issues that can be generated by
the upgrade wizard; however, most of the issues that have a significant impact on
the upgrade effort are considered. As previously stated, the Config – EWIs tab
includes a column that can be used to adjust the effort value obtained for the up-
grade issues to make your estimates more accurate.
Application Dependences
The assessment tool identifies the dependencies between the application compo-
nents analyzing different aspects of the source code, including:
● Application references. Explicit references to user components indicate that there
is a dependence relationship between different user projects.
● Variable declarations. When a variable is declared using a type that is defined in
a different module or project, a dependence relationship between different
modules or projects is established.
● Member accesses. Member accesses also produce dependences between subrou-
tines, functions, or properties.
Figure 3.8
Example Upgrade Order report
The report is divided into sections that correspond to each of the application’s
projects. The files in each group are ordered according to the dependences between
the files in the group. The first file in each group has no dependences on other user-
defined files in the same group. As a result, this file can be upgraded and tested
independently. The next file in the list can be upgraded and tested based on the
previous upgraded file.
Each of these files can be upgraded in a staged way, providing increasing levels of
functionality. The assessment tool produces the Upgrade Order report by looking for
modules that depend on the minimum quantity of user components, and then a new
dependency level is generated based on the components included in the previous
level. In this way, each level is built on the functionality provided by previous levels.
This report is useful for identifying possible upgrade paths; if a horizontal upgrade
strategy is going to be used, the suggested upgrade order can be followed. It is also
possible to upgrade modules from different groups at the same time if a vertical
upgrade strategy will be executed for some pieces of the application.
worksheet. Missing elements are identified according to the user defined modules
and explicit references included in the analyzed projects.
Figure 3.9 illustrates the Missing Components report from the DetailedReport.xls
file.
Figure 3.9
Missing Components report
The Missing Components report includes the file name and path of the missing
components in addition to the corresponding version and the registered name. It is
necessary to install these components on the upgrade computer to execute the
automated upgrade. The quantity of missing components is considered in the effort
estimation (Effort – By Tasks tab in the MainReport.xls file produced by the assess-
ment tool) according to the missing elements configuration data.
Figure 3.10 illustrates the Missing Files report from the DetailedReport.xls file.
Figure 3.10
Missing Files report
This report includes the file name, path, and module type for each missing file. The
project where the missing file is detected is also included. In the same way that the
missing components are considered in the estimation effort, missing user files are
also considered.
Chapter 3: Assessment and Analysis 95
Methodology Overview
It is important to understand the concept of effort in the upgrade context. The effort
of each task is expressed in hours that correspond to normalized time, that is, it
corresponds with the time that the task would take if it was executed using average
resources. If there is a highly experienced programmer in charge of that task, it will
be finished in less time. In addition to average resources provided by default, the
Effort Estimation report includes parameters such as junior developer, junior tester,
senior developer, and senior tester; each with a different cost per hour.
The cost of most tasks is directly derived from the cost of the resources necessary to
perform the tasks and the estimated effort required to execute the task. For example,
the cost of upgrading a COM component is higher if a senior developer is respon-
sible for the conversion, although this may result in reduced effort. In contrast, a
junior developer will cost less than an experienced developer but will require more
time to achieve a functionally-equivalent upgrade. For more specific tasks, the cost
is obtained from a per-occurrence cost that is related to the each task’s degree of
difficulty and the kind of resources necessary to perform it. The Config – General
tab in the MainReport.xls file generated by the assessment tool contains default
values for cost and effort for different upgrade tasks. These values can be modified
96 Upgrading Visual Basic 6.0 Applications
to match more closely to your own development capabilities and costs. Figure 3.11
illustrates the Config – General tab.
Figure 3.11
Config – General tab
Some tasks directly depend on the number of lines of code that comprise individual
components or files. The estimated effort is the number of lines of code multiplied
by some constant. This constant is based on work performed on previous upgrade
projects involving various different types of applications.
For tasks whose cost is derived from the quantity of occurrences of a feature, the
application conversion estimate of effort is calculated by counting up all features’
occurrences within the project and adding the cost to upgrade each occurrence and
the effort per occurrence in terms of time. This is included on the Effort – By Task
tab in the MainReport.xls file generated by the assessment tool, with totals reflecting
time and cost for all occurrences of each feature. Figure 3.12 illustrates a sample of
this tab.
Each EWI has an effort and cost associated with it. All these values are derived from
the steps necessary to resolve each issue in other upgrade projects. These values can
be configured on the Effort – EWIs tab in the MainReport.xls file. An example of this
table is shown in Figure 3.13.
This tab allows you to change the default effort and cost associated with each EWI to
help you prepare a more accurate estimate of the effort required to address upgrade
issues.
Chapter 3: Assessment and Analysis 97
Figure 3.12
Manual Code Adjustment Effort tab
Figure 3.13
Effort – EWIs tab
Aspects to Be Estimated
The different phases to be estimated relate directly to the steps of the upgrade
procedure. In summary, the items to be estimated are:
● Project kickoff. This includes the estimated time for the upgrade project kick-off
meeting. Typically, it is not a large value. It serves as a reminder that these cost
estimates have a well-defined scope. It also reminds you of the many things that
you must do before the upgrade project begins, such as training, research, and
purchasing software and hardware, which are not included here.
● Application preparation. This includes the estimated time for the setup and
verification of the development environment of the original application. This
includes compilation of the original application to verify that it is complete and
source code modifications to accelerate the conversion process later on.
● Application conversion. This includes the estimated time for the execution of the
upgrade wizard and completing the upgrade with manual changes.
● Testing and debugging. This includes the estimated time for the execution of the
original test cases and fixing any run-time errors.
98 Upgrading Visual Basic 6.0 Applications
● Project management. This includes the estimated time for administrative tasks
related to scheduling and management.
● Configuration management. This includes the estimated time for configuration
management of the products obtained throughout the entire upgrade process.
For more information, see Chapter 5, “The Visual Basic Upgrade Process.”
The application composition is the inventory to be upgraded; this is reflected on the
Project Files Overview tab. The inventory of the application is the first aspect to be
considered when estimating the upgrade effort. This inventory will provide a
general vision of the projects and modules to be upgraded. The content of these
modules will be detailed in the Effort Estimation report. The application composi-
tion is an important report to plan the rest of the upgrade and set priorities for the
different projects and modules. For instance, if there are several user controls that
present a dependency among classes, it is wise to set a high priority to those compo-
nents to have them ready when upgrading the forms and classes that depend on
them.
As mentioned in the “Methodology Overview” section, the Config – EWI tab
includes an estimation of the effort needed to upgrade an issue. The values provided
by the assessment tool and that are generated as part of this tab affect the following
worksheets:
● Effort – EWIs
● Effort – By Task
● Effort – Total
The Effort – By Task tab consolidates different aspects of the effort estimation,
including features/code items such as property pages, designers, third-party com-
ponents, ADO, RDO, COM, COM+, and more. Each element is a summary of more
detailed information that can be found in the DetailedReport.xls file.
The tasks included on the Effort – By Task tab have a high degree of detail behind
them, and the estimation is calculated as a function of the data in the details. The
types of resources used to perform the different tasks are also explicitly indicated in
this report to give an idea of the level of experience that each task will likely need,
and the subsequent cost.
this workbook and each has an associated weight indicating the effort required to
upgrade that particular aspect, the weights for some aspects are left at zero. This
means that the assessment tool does not consider that all aspects are important to
the estimation. The aspects that do have weights for effort and cost have values that
may not be appropriate for your organization. Also, remember that every upgrade
project is different, and although similar worksheets to this one have been used in
real upgrade projects, there are always new things to consider or assumptions built
into estimate worksheets that do not apply to every project. It is likely that you will
have to make some adjustments before applying this estimation to your own
projects. For this reason, the next paragraphs explain how the assessment tool
arrives at the cost estimation it produces in the Excel workbook. Every effort has
been made to base the estimates on projects that are as close as possible to typical.
The formulas and weights in Figure 3.14 are based on experience with real upgrade
projects and accurately reflect that experience.
Figure 3.14
Effort –Total tab
The Effort – Total worksheet is divided into three sections: “Application prepara-
tion,” “Application conversion,” and “Testing and debugging.” Each section will be
examined in detail. However, please keep the following notes in mind:
● Most cells in the Effort (Hours) column are references to named cells on the
General Configuration tab or are functions of named cells from there. If you
100 Upgrading Visual Basic 6.0 Applications
make any changes, it is recommended that you make those changes to the Gen-
eral Configuration worksheet instead of to the Effort worksheet.
● Any cell or set of adjacent cells can be given a name and used in formulas. You
will see names used as if they were single values (for example, =NameA+NameB)
and collections of values (for example, =SUM(NameC)).
● For consistency, the worksheets and formulas are organized so that you will only
ever need to change either the General Configuration worksheet or the EWI
Configuration worksheet. The General Configuration worksheet is referenced
primarily in the Total Effort worksheet, and the EWI Configuration worksheet is
referenced mostly in the Upgrade Issues Table worksheet. However, it is okay to
change the other worksheets if you want to. A third worksheet that you will
likely have to change is the Resource Costs worksheet, which specifies how much
it costs for different types of people to work on the upgrade project. These values
change from country to country, from business to business, and even from month
to month, so you will probably have to review them.
Be careful when you make changes to the worksheets generated by the assessment
tool; when it runs again, it will create a new workbook, possibly overwriting all
your changes. Always keep a backup of the workbook file before re-running the
assessment tool. It is recommended that you only make changes to the
MainReport.xls file and keep a backup of it. You can easily change the MainReport
file to link to any DetailedReport.xls file. This saves you from having to reconfigure
the assessment tool or copy configuration information between reports.
Application Preparation
The application preparation phase is described in detail in Chapter 5, “The Visual
Basic Upgrade Process.” In the context of this discussion, the definition of applica-
tion preparation is broadened to include everything from the moment that you are
preparing the computers the upgrade will be performed on up to just before the
upgrade wizard runs for the last time to generate the initial code that will be used as
the source base for the new Visual Basic .NET application.
This does not include the time spent studying alternatives or any of the other activi-
ties that are performed before an upgrade project is approved. It is assumed that the
decision to upgrade has already been made and that the upgrade project has been
approved.
Nor does it include any “code preparation” activities that are described in Chapter 5,
such as running the Visual Basic Code Advisor to clean up the code to make it more
amenable to upgrade. These activities can help reduce overall upgrade time but
including them in these estimations would make them overly complex. We suggest
that you use the assessment tool after you do any code preparation. If your code
preparation is successful, you should see a reduction in the effort estimated by the
assessment tool before and after code preparation is complete.
Chapter 3: Assessment and Analysis 101
Most of the tasks in this phase have fixed estimations of effort and cost or have
estimations based on the number of lines of code in the application. These are
explained here:
● Development environment. This includes the setup of the upgrade wizard,
which will be used to analyze and upgrade the application. This effort is fixed
and configurable by the user of the assessment tool.
● Application resource inventory. This includes an initial review of the application
and gathering all the files and tools that are needed to compile the application in
Visual Basic 6.0. It also includes time for collecting existing information about the
applications architecture and design. This value depends on the size of the
application.
● Compilation verification. The original application is compiled to verify that all
the required files are available. This effort is fixed and configurable by the user of
the assessment tool.
● Upgrade order definition. The upgrade order is determined by the assessment
tool reports and priorities that are implied by your own strategic and technical
goals. This value also depends on the size of the application.
● Upgrade wizard report review. Preliminary test upgrade of the application to test
the system resources and detect common errors and practices that are more easily
fixed in Visual Basic 6.0. This task also depends on the size of the application.
Application Conversion
The application conversion phase includes all the tasks required to get the green code
to functional equivalence. Green code is the name for the unmodified code gener-
ated by the upgrade wizard that serves as the initial code base for the upgrade.
The tasks in this phase are:
● Upgrade wizard execution. This involves execution of the upgrade wizard to
obtain the green code. This effort depends on the size of the application.
● Issue resolution. This involves manual resolution of all the issues mentioned in
the Effort – EWIs worksheet. This sheet is described in greater detail later in this
chapter.
● Code review. After all the issues are resolved, it is necessary to integrate all the
new code, compile it, and debug it.
● Administrative tasks. This involves administrative tasks performed during this
phase, such as scheduling and resource assignment. It is calculated as a percent-
age of all the other tasks in this phase.
102 Upgrading Visual Basic 6.0 Applications
Config – General
The Config – General tab allows you to configure the estimated effort for specific
upgrade issues, such as correcting and verifying every 1,000 lines of code. It includes
the following columns:
● Migration Task. This column includes tasks that must be performed during the
upgrade. Some of the tasks refer to specific characteristics of the application (such
as lines of code) or types of components used by the application (such as COM
objects or ADO).
● Effort per occurrence (Hours). This column defines the time required to upgrade
an occurrence of an upgrade task, measured in hours. This value should be
configured to reflect the capabilities of the developers in your company. The
default value is usually a good average.
● Cost per hour. This column identifies the cost per hour of upgrading an occur-
rence of one of these issues. This is highly variable and depends on the skill level
of the person that will be working on each issue and the salary levels for someone
of that level.
● Resource. This column identifies the recommended resource type that should be
assigned to resolving each issue.
● Description. This column provides a description for each upgrade task.
Config – By Resources
Resource costs can be found in the Config – By Resources tab. They represent an
estimation of development resources required to resolve an upgrade issue. Figure
3.15 shows an example Config – By Resources tab.
Figure 3.15
Config – By Resources tab
104 Upgrading Visual Basic 6.0 Applications
Figure 3.16
Config – Fixed Task tab
The Config – Fixed Tasks tab includes the following three columns:
● Task. This column lists some common tasks that are a part of every upgrade
project.
● Hours. This column lists the time required to complete each task. Again, this may
need to be changed to reflect you own circumstances.
● Description. This column provides a description of each task.
Config – EWIs
The Config – EWIs tab displays information about the upgrade estimates for EWIs.
It includes the following seven columns:
● Name. This column contains the name of each error, warning, and issue.
● MSDN ID. This column contains the Microsoft Developer’s Network ID of the
EWI.
● Resource. This column identifies the recommended resource type that should be
assigned to resolving each EWI.
Chapter 3: Assessment and Analysis 105
● Effort per occurrence (Minutes). This column defines the time required to up-
grade an occurrence of an upgrade EWI measured in minutes. This value should
be configured to reflect the capabilities of the developers in your company. The
default value is usually a good average.
● Effort per occurrence (Hours). This column is the same as the preceding one,
except the time is displayed in hours instead of minutes.
● Cost per hour. This column identifies the cost associated with the upgrade of
each issue by an average developer. This is highly variable and depends on the
skill level of the person that will be working on each issue and the salary levels
for someone of that level.
● Functionality. This column contains a more detailed description of the EWI.
Summary
A successful upgrade project depends on careful assessment and analysis of the
project to upgrade. A thorough application of these tasks ensures accurate planning
and budgeting. This chapter discussed the information you need to gather to per-
form these tasks and some of the tools available to help you gather it.
More Information
For more information about improving the performance of your applications, see the
white paper titled “Advantages of Migrating from Visual Basic 6.0 to Visual Basic
.NET” on MSDN:
http://msdn.microsoft.com/vbasic/productinfo/advantage/default.aspx.
For more information about the Visual Basic Companion from ArtinSoft, go to the
ArtinSoft Web site:
http://www.artinsoft.com/Default.aspx.
4
Common Application Types
This chapter can help you to understand how common Visual Basic 6.0 application
types are treated before, during, and after an upgrade. The chapter explores the
dependencies between an application type and the application’s actual architecture
from an upgrade perspective. After you have made the decision to upgrade, use this
chapter to learn about the similarities and differences between Visual Basic 6.0 and
Visual Basic .NET application types, and how to achieve a smooth transition that
takes advantage of features available in the upgraded version.
This chapter provides a high-level summary of the upgrade process for each applica-
tion architecture and type.
For a summary of how to upgrade these component types, see the “Application
Components” section later in this chapter.
Architecture Considerations
As explained in Chapter 2, “Practices for Successful Upgrades,” you may need to
approach the upgrade by using one of the following two approaches:
● Vertical upgrade. This approach requires that you isolate and replace a piece of
your application through all n tiers.
● Horizontal upgrade. This approach requires that you replace an entire tier of
your application.
To assure functional equivalence independently of your chosen approach, you must
have comprehensive unit and system test suites for the entire application, as well as
for individual upgrade modules, components, or tiers. You may find it convenient to
upgrade portions of the application that you can test in the early stages of the
process. This approach allows you to have different developers or development
teams work in parallel, and it helps you to correct issues early in your project.
However, as explained in the forthcoming sections, it is not always feasible to
independently upgrade and test pieces of an application.
For more information about testing and debugging an upgraded application, see
“Testing and Debugging the Upgraded Application” in Chapter 5, “The Visual Basic
Upgrade Process,” and Chapter 21, “Testing Upgraded Applications.”
110 Upgrading Visual Basic 6.0 Applications
Single-Tier Applications
Single-tier (or monolithic) applications are applications in which most or all of
the code for a given feature is contained in a single source code file. In Visual Basic,
this usually means that all of the functional logic is in the control event handler
subroutines. All necessary components and functionality are included in a group of
forms, making them the conceptual units for the application features. In such appli-
cations, development tends to be driven by the user interface. If new features are
needed in the application, new components are built into existing forms. For ex-
ample, when a single-tier application requires database access, then a component for
data access is plugged into the form, and all methods that need to access the data-
base use the newly integrated component.
Single-tier applications do not have separate functional layers for data access,
business logic, or the user interface. All necessary services and components are
integrated in the same development unit (usually a form). This kind of application is
highly coupled because all components are closely tied together, usually in the same
file or procedure, with many shared structures and connection points. A single-tier
application also has low cohesion, which means that the mechanisms that constitute
different conceptual entities are so closely tied together that conceptual barriers are
obscured. This makes modifying functionality difficult because making a change can
affect more than just the intended functional behavior.
When you compile an application of this type, you generate a single executable file
that contains all of the necessary information for user-defined forms and modules.
To deploy such an application, you must install the executable file and any related
third-party components on each of user computer.
The remainder of this section describes issues that you should consider when you
upgrade a single-tier application.
Although the example uses a single multiple-document interface (MDI) child form,
the concepts presented also apply to solutions composed of several forms and
modules and to Web applications that are highly coupled.
The form in this example (which could just as easily be a Web page) allows a user to
have a general overview of the telephone calls received at an IT help desk. After the
user locates a record, he or she can request more information about it. The form
contains a data-bound grid that displays records in a table with telephone call data.
The grid uses an ActiveX Data Object (ADO) data control as its data source: the data
control provides the communication with the system’s database. Because the form
displays the full list of calls, the control has been made invisible. Figure 4.1 provides
an overview of the form components and architecture.
Chapter 4: Common Application Types 111
DataGrid
Database
Figure 4.1
Typical monolithic form components
The outer box represents the single tier application, which contains the telephone
calls search form. This form includes components for data access, business logic, and
visual components, represented in the diagram by the smaller boxes. The arrows in
the diagram show the dependences between components. The visual behavior code
manages the rest of components, The DataGrid control uses an ADO data control to
display the information extracted from the database. The business logic interprets
the telephone numbers if a user requests details about a call. Although the boxes
related to business logic and data access are shown as independent entities, the
corresponding code could be intermixed with the rest of the form’s code. Note also
that all of the functionality is enclosed in the telephone call search form and cannot
be used by any application modules outside this form.
Because the complete functionality of this example is encapsulated in a single form,
it must all be upgraded and potentially adjusted before the form can be compiled,
executed, and tested. For example, the business logic included in the form cannot be
upgraded and tested independently of the rest of the code unless the developer
rearchitects the original form. The monolithic structure of the application makes an
incremental upgrade and test of isolated functionality extremely difficult. The form
and all its elements must be upgraded as a single functional unit that constitutes the
entire application. In this sense, the upgrade strategy to be followed for a monolithic
application is a complete upgrade strategy.
112 Upgrading Visual Basic 6.0 Applications
generates a NET solution file that contains only this project.) When the wizard
upgrades a typical single-tier application, it replaces all library references with
references to the common equivalents in the .NET Framework base class library.
References to the System namespace provide basic functionality for the Form class
and XML capabilities. The Microsoft.VisualBasic assembly provides functions that
are similar to the functions available in the Visual Basic 6.0 VBA library. Each class
library that was referenced in the original application will have a corresponding
reference in the Visual Basic .NET project. ActiveX control (.ocx) components will
have an additional reference that begins with the prefix Ax and corresponds to a
Windows Forms control wrapper. These references are generated by the aximp
utility. For example, a reference to the component MSComctlLib for common
controls results in a new reference to AxMSComctlLib. This additional reference
provides support for the native members and behavior that all Windows Forms
controls support.
The upgraded application will have the same structure as the original. All of the
original relationships between application components are in the upgraded version.
The Visual Basic Upgrade Wizard automatically generates interoperability wrappers
for all ActiveX components that require it. For example, in the telephone calls
example form described earlier, a wrapper is generated for the DataGrid and ADO
components. For more information about interoperability, see the “Application
Components” section later in this chapter.
It is important to note that the remaining components are upgraded to native .NET
Framework classes, and most of the source code is converted to Visual Basic .NET.
You can manually upgrade the wrapped ActiveX components to native .NET com-
ponents after applying the automatic tools. For example, you can upgrade ADO to
ADO.NET and upgrade the DataGrid control to the .NET Framework DataGrid or
to a third-party data grid. However, manual adjustments require more time and
effort to achieve.
Two-Tier Applications
A two-tier application is composed of a first tier — the user interface tier — that
contains a user interface and business logic, and a second tier — the data tier — that
contains all of the data access components. The user interacts with the interface tier,
and uses it to perform all application-specific functions. The data tier contains all
data sources and manages them so that they can provide all necessary data services
to the user interface tier.
The user interface of a Visual Basic 6.0 application can contain forms, Web pages,
or both. Additionally, a Visual Basic 6.0 application can have a front end that can be
accessed programmatically. In addition, enterprise applications can have rich forms
clients as well as thin Web clients that can be accessed remotely.
114 Upgrading Visual Basic 6.0 Applications
Figure 4.2 shows a two-tier application form based on the telephone list and filter
window explained in the previous section. In this example, the data access compo-
nents are no longer part of the form module. Instead, they are defined indepen-
dently, which allows for modularity and code reuse. This architecture also offers
more upgrade alternatives than the single-tier architecture. The separation of tiers
permits each tier to be upgraded and tested independently. This gives more flexibil-
ity to the upgrade plan.
A two-tier application can be upgraded horizontally or vertically. If you select a
horizontal strategy, you can update an entire tier and leave the remaining tier
unchanged. The upgraded tier can use interoperability features to work with the tier
that was not upgraded. You can then upgrade the remaining tier and integrate it into
the target application as time and budget permits. Alternatively, you can use a
vertical upgrade strategy as explained in the previous section.
DataGrid
UI Tier
Data Tier
Data Access
Class
ADO
Database
Figure 4.2
Typical two-tier application architecture
Chapter 4: Common Application Types 115
When you upgrade a two-tier application, the upgrade wizard produces a Visual
Basic .NET project that contains files and references similar to those produced for a
single-tier application. The main difference is that a data access class is included in
the project files. This class is independent of the other classes and provides services
that can be used by any other class. This class contains some wrapped classes that
correspond to low-level data access classes (ADO) to provide basic services. If you
manually upgrade ADO to ADO.NET, you must also change this data access class.
However, if your application was designed in a modular way (with low coupling),
you need to make only minimal changes to the rest of the application because
internal changes in the user-defined data access class will not affect its users.
Three-Tier Applications
A three-tier application maximizes component cohesion and minimizes tier cou-
pling. This architecture uses three different tiers for the different aspects of the
application: a user interface tier, a business logic tier, and a data tier. The difference
between a three-tier and a two-tier application is the addition of a business logic tier.
The business logic tier contains application rules and algorithms; therefore, the user
interface tier is only responsible for managing the interaction between the user and
the application. The business logic tier can be segmented into additional logical tiers
to produce a multi-tier architecture. The components of the business logic tier can
also have a close interaction with the data tier. Figure 4.3 on the next page shows a
typical three-tier application.
Because of the further separation of tiers, an upgrade strategy for a three-tier appli-
cation can be even more flexible than an upgrade strategy for a two-tier application.
As with two-tier applications, a three-tier application can be upgraded in a horizon-
tal or vertical way. By using a horizontal strategy, you can upgrade all or part of a
tier and leave the other tiers unchanged. The upgraded code can use interoperability
features to access the unchanged code. Then, you can gradually upgrade the other
tiers and integrate them into the application.
Another important feature of a three-tier architecture is that it allows you to take
advantage of specialized skills that your developers may have, and have them work
in parallel. For example, one developer or development team could work on modu-
lar user interface components while other developers upgrade and adjust the com-
ponents in the business logic and data access tiers.
When you upgrade a three-tier application, the resulting application will also have
three tiers. The upgrade wizard generates ActiveX wrappers for components used in
the UI tier. It is probable that you will need to perform additional UI testing because
some of the UI components require wrappers, custom upgrades, or reimplementa-
tion. However, you can reduce the associated risks by upgrading the UI tier first and
connecting it to the other tiers by using interoperability, while you test the UI tier
early in your project. This approach allows you to upgrade, test, and integrate the
116 Upgrading Visual Basic 6.0 Applications
other tiers in parallel. For additional advice about which tier to upgrade first, see
Chapter 2, “Practices for Successful Upgrades.”
UI Tier
Business
Logic Tier Business logic
Data Tier
Data Access
Class
ADO
Database
Figure 4.3
Typical three-tier application architecture
Desktop Applications
To create a Visual Basic 6.0 desktop application, you use the standard executable
project template. By default, this template starts with an empty form that becomes
one of the primary interfaces. The Visual Basic 6.0 integrated development environ-
ment (IDE) allows you to include supplementary components and references to take
advantage of existing functionality.
A typical desktop application that uses a highly coupled architecture consists of a fat
client, possible middle-tier COM components with business logic, a data access tier,
and a connection to a data store. In this type of application, the presentation and
business logic reside on the client.
In general, a desktop application had the following characteristics:
● Intended usage. The application has many visual cues or aids and provides a
complex interaction with the user.
● Architecture. The application architecture is flexible: for example, it can be a
single tier, fully coupled application or a completely modular application with
well-defined business logic and data access tiers.
● Necessary capabilities. The application requires user interface components, basic
services, and data access functionality. Multithreading capability may be re-
quired, but synchronized process distribution is rarely needed unless the applica-
tion uses the distributed component object model (DCOM) or COM+.
The Visual Basic 6.0 to Visual Basic .NET Upgrade Wizard automatically upgrades
desktop applications to be Visual Basic .NET Windows-based applications. The
wizard does not change the general organization of the code. Therefore, the original
application tiers remain intact. However, there are architecture-related issues that
you should consider when you upgrade a desktop application. These issues include
the following:
● Language issues. You may need to perform additional manual upgrading to
resolve language issues, such as external DLL function declarations or thread
safety. This work can include creating or changing classes so that they provide
basic API services or synchronization among objects. You can upgrade external
declarations to .NET Framework classes and new interface classes. In addition,
you may need to add references. Note that Visual Basic .NET components (in-
cluding UserControls) are not inherently thread-safe. Multiple threads are
allowed to access a component simultaneously. As a result, code that is thread
safe in Visual Basic 6.0 can be unsafe when it is upgraded to Visual Basic .NET.
This change will affect you if you are running your component in a
multithreaded environment such as Internet Explorer, Internet Information
Services, or COM+.2 In this case, you must include new synchronization mecha-
nisms to ensure thread safety.
118 Upgrading Visual Basic 6.0 Applications
Web Applications
In most cases, you would use the following technologies to build a Web site or Web
application with Visual Basic 6.0:
● Active Server Pages (.asp). This is a server-side scripting run-time environment
used to create interactive Web server applications. An .asp file can include HTML
sections, script commands, and COM components that execute on the Web server
and render a Web page for the client.
● Internet Information Server (IIS) projects. These are applications composed of
WebClasses that run on the Web server and respond to HTTP requests from
Chapter 4: Common Application Types 119
clients. WebClasses can handle state information for the application. For more
information about upgrading an IIS project, see Appendix C, “Introduction to
Upgrading ASP,” and Chapter 10, “Upgrading Web Applications.”
The functionally equivalent server-side technology in Visual Studio .NET is
ASP.NET. This is not simply a new version of ASP. It has been entirely redesigned
based on the .NET Framework. This section highlights the main considerations that
you should take into account when you upgrade ASP code to ASP.NET.
Figure 4.4 shows the general architecture of a Visual Basic 6.0 Web application.
A client Web browser sends a request to IIS, and IIS responds by rendering active
server pages. The ASP files access COM components that contain part of the
application’s business logic and data access layers. These components run in the
Web server computer or in an application server. The larger, background boxes
represent platform servers that provide functionality to different conceptual tiers;
for example, the Web server box includes business logic functionality and part of the
user interface functionality because it has to provide presentation elements as well
executable code in ASP files. The ASP files include application logic and presenta-
tion elements in a single module; that is why the active server pages box crosses the
barrier between the UI tier and the business logic tier.
Web Browser
Web Server
UI Tier
Active Server
Pages
Application Server
Internet
Business
Information Business Logic
Logic Tier
Services Components
Data Tier
Data Access
Class
Database
Figure 4.4
Visual Basic 6.0 Web application architecture
120 Upgrading Visual Basic 6.0 Applications
Figure 4.5 shows the architecture of an ASP.NET Web application. If you compare
Figure 4.4 to Figure 4.5, you can see the underlying differences between the two
technologies, and where you need to focus your upgrade efforts.
Web Browser
Data Tier
Data Access
Class (ADO.NET)
Database
Figure 4.5
ASP.NET Web application architecture
In a transition from ASP to ASP.NET, most of the architecture changes occur in the
components to be deployed on the Web server. The Web document model is com-
pletely changed. In ASP.NET, Web pages are built as Web forms, which have sepa-
rate files for document content and document presentation logic and behavior.
Therefore, the business logic and user interface aspects of Web pages are separate. In
this model, the Web form content box is included in the UI tier, and the Web form
executable code (Web form assembly) is included in the business logic tier. The
ASP.NET run-time component provides additional services, including Web security,
caching, and other performance features.
Chapter 4: Common Application Types 121
Coexistence
ASP and ASP.NET can coexist on the same Web server; however, they are executed
as different, non-communicating processes.
A Web application within a site can contain both ASP.NET pages and ASP pages.
This offers some advantages if you need to move a large, functionally disjointed and
rapidly changing site to ASP.NET one piece at a time. You can upgrade different
sections of the application that do not depend on each other to ASP.NET, and they
can coexist with the rest of the application. If you are transitioning to ASP.NET as a
long-term strategy, you should use this opportunity to make as many architectural
and design improvements as you can. For more information about upgrading to
ASP, see “Migrating to ASP.NET: Key Considerations” on MSDN.
Because the same Web server can access both ASP and ASP.NET pages, you do not
need to upgrade your existing ASP pages to ASP.NET – compatible pages. However,
there are many advantages to doing so. Some of the biggest advantages include the
following:
● Increased performance. Independent tests have shown that ASP.NET applica-
tions can handle two to three times the requests per second as classic ASP appli-
cations. For more details about performance improvements, see Chapter 1,
“Introduction.”
● Increased stability. The ASP.NET runtime closely monitors and manages pro-
cesses. If a process malfunctions (for example, if it leaks or deadlocks), ASP.NET
can create a new process to replace it. This helps to keep your application avail-
able to handle requests.
● Increased developer productivity. Features such as server controls and event
handling in ASP.NET can help you to build applications more rapidly and with
fewer lines of code. It is also easier to separate code from HTML content.
For more information about converting to ASP.NET, see “Converting ASP to
ASP.NET” on MSDN.
successfully upgrade these foundation components, you can convert the ASP code
by using the ASP to ASP.NET Migration Assistant.
For a detailed discussion of the ASP to ASP.NET Migration Assistant, see Appendix
C, “Introduction to Upgrading ASP.”
Key Considerations
When you upgrade existing ASP pages to ASP.NET pages, you should also be aware
of the following:
● Core API changes. The core ASP APIs have a few intrinsic objects (Request,
Response, Server, and so on) and their associated methods. With the exception of
a few simple changes, these APIs continue to function correctly under ASP.NET.
● Structural changes. Structural changes are those that affect the layout and coding
style of ASP pages. You need to be aware of several of these to ensure that your
code will work in ASP.NET.
● Visual Basic language changes. There are some changes between VB Script and
Visual Basic .NET script that you should prepare for before you upgrade your
application.
● COM-related changes. COM has not been changed at all. However, you need to
understand how COM objects behave when you use them with ASP.NET.
● Application configuration changes. In ASP, all Web application configuration
information is stored in the system registry and the IIS metabase, while in
ASP.NET each applications has it own Web.config file.
● State management issues. If your application uses the Session or Application
intrinsic object to store state information, you can continue to use these in
ASP.NET without any problems. As an added benefit, ASP.NET provides addi-
tional options for your state storage location.
Chapter 4: Common Application Types 123
● Base class libraries. The base class libraries (BCL) provide a set of fundamental
building blocks that you can use in any application you develop, whether your
application is an ASP.NET application, a Windows Forms application, or a Web
service. You can significantly improve your application by using the BCL.
For information about each of these concerns, see Appendix C, “Introduction to
Upgrading ASP” and “Migrating to ASP.NET: Key Considerations” on MSDN.
The deployment of an upgraded Web application requires the installation of a client
and one or more server computers. All necessary client-side ActiveX components
must be installed on the client. The server must be set up with the complete set of
server controls, component libraries, and data providers.
Application Components
Microsoft developed the component object model (COM) to allow interaction
between applications and to provide a platform for code reuse.
You can create the following types of COM components with Visual Basic 6.0:
● ActiveX code libraries. You can compile these components as COM executable
programs or as DLLs. These libraries include classes that you use by creating
instances in the client application. In Visual Basic 6.0, the project templates you
use to create these COM components are referred to as ActiveX executables and
ActiveX DLLs.
● ActiveX controls. These controls are standard interface elements that allow you
to rapidly assemble reusable forms and dialog boxes.
● ActiveX documents. ActiveX documents are COM components that must be
hosted and activated within a document container. This technology permits
generic shell applications, such as Internet Explorer, to host different types of
documents.
This section provides general information that you can use when you upgrade any
type of supported application component.
● The names of resources used in the assembly, including information about which
resources are exported from the assembly.
● Compile-time dependencies on other assemblies.
The .NET common language runtime (CLR) uses this information to resolve refer-
ences, enforce version binding policy, and validate the integrity of loaded assem-
blies. By using the assembly manifest, the CLR eliminates the need to register .NET
components in the system registry before a client application can use them, and
therefore simplifies application deployment and reduces versioning problems. Most
end users and developers are familiar with versioning and deployment issues that
can occur in component-based systems. Many of these issues are related to the
registry entries that are necessary to activate a COM class. The use of assemblies in
the .NET Framework solves a high percentage of these deployment problems.
Assemblies facilitate zero-impact application installation, and they simplify
uninstalling and replicating applications.
Versioning Problems
Currently two versioning problems occur with Win32 applications:
● Versioning rules cannot be expressed for pieces of an application and enforced by
the operating system. The current approach relies on backward compatibility,
which is often difficult to guarantee.
● There is no way to maintain consistency between sets of components that were
built together and the set that is present at run time.
These versioning problems combine to create DLL conflicts, where installing one
application can inadvertently break an existing application because a certain soft-
ware component or DLL was installed that was not fully backward compatible with
a previous version. After this problem occurs, there is no support in the system for
diagnosing and fixing the problem.
Chapter 4: Common Application Types 125
.NET Interop
Marshaling Service
Method
Calls
COM Object RCW .NET Client
Figure 4.6
Accessing a COM component through interoperability
In Figure 4.6, the Type Library Importer utility (Tlbimp.exe) analyzes the COM
library, and converts the type definitions to equivalent definitions in an assembly
that contains metadata which corresponds to the original COM library. The CLR.
creates a runtime callable wrapper (RCW) for each COM object. The main function
of the RCW is to marshal the calls between the .NET client and the COM object. This
marshaling includes the conversion of data types so that the two technologies can
communicate. The .NET client can access the COM library by using the RCW as an
intermediary.
The interoperability wrapper created is a .NET assembly that wraps the COM
component. The assembly must be registered in the global assembly cache if it will
be shared by different applications. There are several reasons why you might want
to put an assembly in the global assembly cache:
● The global assembly cache provides a central location for shared assemblies. If
an assembly will be used by multiple applications, it should be put in the global
assembly cache.
● The global assembly cache can improve file security. Administrators often
protect the WINNT directory by using an access control list (ACL) to control
write and execute access. Because the global assembly cache is installed in the
WINNT directory, it inherits that directory’s ACL.
● The global assembly cache allows side-by-side versioning. The global assembly
cache can maintain multiple copies of assemblies with the same name, but differ-
ent version information.
● The global assembly cache is the primary CLR search location. The common
language runtime checks the global assembly cache for an assembly that matches
the assembly request before probing or using the code base information in a
configuration file.
Chapter 4: Common Application Types 127
For more information about wrappers, see “Customizing Standard Wrappers” in the
.NET Framework Developer’s Guide on MSDN.
Despite the advantages, you should share assemblies by installing them in the global
assembly cache only when necessary. As a general guideline, keep assembly depen-
dencies private and place assemblies in the application directory unless sharing an
assembly is explicitly required. In addition, you do not have to install assemblies in
the global assembly cache to make them accessible to COM Interop or unmanaged
code.
Note that there are situations where you should not install an assembly into the
global assembly cache. For example, if you place one of the assemblies in an applica-
tion in the global assembly cache, you can no longer replicate or install the applica-
tion by using XCOPY installation. In this case, you must place all of the application’s
assemblies into the global assembly cache. For more information about working
with assemblies, see “Working with Assemblies and the Global Assembly Cache” in
the .NET Framework Developer’s Guide on MSDN.
There are two ways to install an assembly in the global assembly cache:
● Use Microsoft Windows Installer 2.0. This is the recommended and the most
common way to add assemblies to the global assembly cache.
● Use the Global Assembly Cache tool (Gacutil.exe). This approach is recom-
mended for development purposes. However, you should not use this approach
to add production assemblies to the global assembly cache.
Reusable Libraries
Visual Basic 6.0 components can run in any one of three places:
● In the same address space as the client (in-process).
The rest of this section explains how to upgrade of ActiveX code components. These
components correspond to the Visual Basic 6.0 ActiveX DLL project template.
In most cases, code components have no user interface. Instead, they consist of
libraries of classes that allow client applications to instantiate objects based on those
classes. In earlier documentation, code components were referred to as OLE Auto-
mation servers.
The equivalent .NET project for an ActiveX DLL is a .NET class library. The Visual
Basic Upgrade Wizard automatically upgrades most of the code inside the original
ActiveX DLL project and generates the corresponding Visual Basic .NET project
type. After an automated upgrade, you will have language issues that you must
correct manually. For an explanation on unsupported language features, see Chap-
ters 7 – 11.
Visual Basic .NET class libraries contain reusable classes or components that can be
shared with other projects. This project type is considered to be windowless and will
not contain a Windows Form class; this restriction may be an obstacle for you if you
used the Visual Basic 6.0 code component library to provide standard libraries of
modal and modeless dialogs. However, the Visual Basic Upgrade Wizard upgrades
form objects and compiles them inside the component. If it is necessary to allow
other applications to use these form classes, you must change the corresponding
access level from Friend to Public.
To further improve your application, you should move all visual classes to another
component. This will separate the presentation and business tiers that exist in a
single component and produce a more modular architecture.
ActiveX Controls
An ActiveX control is a COM component with user interface elements. ActiveX
controls were previously known as OLE controls or OCX controls. These controls
can be used in the same way as any of the standard built-in controls, and provide an
extension to the Visual Basic 6.0 toolbox. ActiveX controls created in Visual Basic can
be used in different container applications, including Visual Basic applications,
Microsoft Office documents, and Web pages accessed through a Web browser like
Microsoft Internet Explorer.
An application can provide ActiveX controls with other Visual Basic 6.0 components,
or it can access and use third-party ActiveX controls. If the ActiveX controls are
components in your application, you can use the Visual Basic Upgrade Wizard to
upgrade the source code for the control. If the ActiveX control source code is not
available, you can replace the control with other upgraded components or you can
use interoperability to access the control, as described previously in this chapter. The
remainder of this section explains how to upgrade user-defined ActiveX controls.
Chapter 4: Common Application Types 129
When you upgrade a user-defined ActiveX control to Visual Basic .NET, you can
include it in the control toolbox, just as you would any pre-defined control. User-
defined ActiveX controls appear in the User Control Tab of the toolbox, while the
predefined controls appear in the General tab of the toolbox. You can place in-
stances of the upgraded control on .NET Windows Forms, and you can set the
control’s design time properties by using the .NET form editor.
You can use property pages to define a custom interface for setting properties of an
ActiveX control; this is an extension of the Properties window. However, the Visual
Basic Upgrade Wizard does not support this feature, and you must reimplement the
property page user interface, synchronize the property values and the state of the
control, and associate the control properties and dialog box fields. For more infor-
mation, see Chapter 9, “Upgrading Visual Basic 6.0 Forms Features.”
controls are more abstract than HTML server controls in that their object model
does not necessarily reflect HTML syntax.
● Validation controls. These are controls that incorporate logic to allow you to test
a user’s input. You can attach these controls to an input control to test what the
user enters for that input control. Validation controls are provided to allow you to
check for a required field, to test against a specific value or pattern of characters,
to verify that a value lies within a range, and so on.
● User controls. These are controls that you create as Web Forms pages. You can
insert Web Forms user controls in other Web Forms pages, which is an easy way
to create menus, toolbars, and other reusable elements.
These control types provide reimplementation alternatives for ActiveX controls
embedded in Web pages. Depending on the functionality of the original ActiveX
control, you may find it convenient and appropriate to implement it as a Web
control. For example, if an application has an ActiveX control that communicates
with different servers to obtain and process data, it is generally more efficient to
create a new Web server control that executes the communication and heavy pro-
cessing on the server and renders visual elements to the Web client.
The ASP to ASP.NET Migration Assistant tool treats ActiveX controls embedded in
Web pages as HTML tags and keeps them in the target ASP.NET files. Therefore,
these elements of the Web page are not automatically transformed. You must manu-
ally complete any further upgrades.
You should wait until after you complete the initial (automatic) upgrade before you
re-implement any components. After you reach functional equivalence, you can
complete any re-implement as part of the upgraded application advancement. For
more information about this process, see Chapter 17, “Introduction to Application
Advancement” or “Introduction to ASP.NET Server Controls” on MSDN.
ActiveX Documents
ActiveX documents are COM components that must be hosted and activated within
a document container. They provide the application functionality; they also provide
the ability to persist and distribute copies of the data intrinsic to the application.
These components can be used on HTML pages or as alternatives to HTML pages,
and they can be deployed so that users can navigate transparently between ActiveX
documents and other pages in the application or Web site.
The .NET Framework does not have a component type equivalent to ActiveX docu-
ments. Therefore, you must redesign and/or re-implement ActiveX documents by
using a .NET Framework – based component.
The following list presents important ActiveX document features that you should
consider when you upgrade to Visual Basic .NET:3
132 Upgrading Visual Basic 6.0 Applications
● Automatic downloading of components over the Internet. You can create a link
to the ActiveX document so that the browser can find and download all compo-
nents that are needed to run the component.
● Hyperlinking of objects. In a hyperlink-aware container, you can use the proper-
ties and methods of the Visual Basic Hyperlink object to jump to an URL or
navigate through the history list.
● Interaction with the container window. You can use ActiveX documents to
access additional pieces of the container window; for example, the component
menus can be merged with the browser menus.
● Storing of data. When you deploy an ActiveX document in Internet Explorer, you
can store data through the PropertyBag object.
You can use the upgrade wizard to partially upgrade ActiveX documents if you
move the ActiveX document source code to another module type that the upgrade
wizard supports. For example, you can copy the source code and the controls
contained in the ActiveX document into a new Visual Basic 6.0 UserControl. A
considerable portion of the UserControl source code will be automatically up-
graded; however, all unsupported features in the original ActiveX document source
code will not be upgraded and must be re-implemented.
You can re-implement ActiveX document components by using Visual Basic .NET
UserControls or XML Web forms, which can be hosted in different types of contain-
ers. You will lose some of the original functionality unless you redesign and imple-
ment it in the new platform. You can implement most of this functionality by using
the services provided by the .NET Framework, such as serialization interfaces and
the ability to run at the server or at the client depending on your chosen design.
Distributed Applications
A distributed application is one in which some of the application components are
executed on remote computers and there is interaction between local and remote
components. To have an effective interaction between these components, you must
use numerous basic services, such as communication protocols, security, and re-
source locator services. A distributed application offers important advantages for
the enterprise environment, including improved scalability, reliability and failure
tolerance.
The following sections describe some of the things you should consider when you
upgrade components of distributed applications.
DCOM Applications
The distributed component object model (DCOM) extends the component object
model (COM) to support communication between objects on different computers on
Chapter 4: Common Application Types 133
a local area network (LAN), a wide area network (WAN), or even the Internet. With
DCOM, your application can be distributed to any location that makes sense to your
users and to the application.
DCOM is an extension of COM; therefore, you can use your existing COM-based
applications, components, tools, and knowledge when you move to DCOM. DCOM
handles low-level details of network protocols.
Remoting is considered to be the .NET equivalent of DCOM. It is a framework
designed to simplify communication between objects. Remoting supports communi-
cation between objects that exist in different application domains and have different
contexts, regardless of whether or not the objects are on the same computer or even
the same application domain.
The remoting framework is built into the common language runtime and can be
used to build sophisticated distributed applications. Some of the features provided
by .NET remoting are:4
● Proxy objects. .NET remoting creates a proxy object when a client activates a
remote object. The proxy object acts as a representative of the remote object. All
calls made to the proxy are forwarded to the correct remote object instance.
● Object passing. The remoting framework provides mechanisms for passing
objects between applications. These mechanisms handle the marshaling details.
● Activation models. .NET remoting provides more than one way to activate
remote objects.
● Stateless and stateful objects. .NET remoting provides many ways to achieve
state management and to manage stateless objects.
● Channels and serialization. .NET remoting provides a transport mechanism
called .NET channel services to transport messages between applications and
application domains. .NET provides serialization (it can transport objects across
byte streams) and uses formatters to encode and decode these byte streams.
● Lease-based lifetime. .NET remoting allows the application to control the length
of time that a client can remain connected to a remote object by using a lease.
When the lease expires, the object is automatically disconnected. .NET remoting
also provides methods to extend a lease when needed.
● Hosting objects in IIS. .NET remoting objects can be hosted in any .NET-based
executable or managed service, but they can also be hosted in IIS. This allows
remoting objects to be exposed as Web services.
You can upgrade a Visual Basic 6.0 application that uses distributed component
technologies to Visual Basic .NET in two different ways:
● By using new COM classes
The following sections describe the advantages and disadvantages of each approach.
There are several reasons why you may need to perform for this type of separation,
including scalability, manageability, accountability, and performance. Microsoft
provides two main technologies to create this type of architecture: Microsoft Trans-
action Server (MTS) and COM+.
MTS provides transaction services, which facilitate the transition from single-user to
multi-user architectures and provide application infrastructure and administrative
support for building scalable and robust enterprise applications. Although transac-
tion management is an integral part of many applications, MTS also provides useful
services for applications that do not use transactions at all.
Components that encapsulate application logic can run under the control of MTS
and are invoked by presentation services from a variety of clients, including:5
● Traditional applications that were developed in Visual Basic or other languages
that support COM.
● Web browsers.
You can use Visual Basic 6.0 with MTS to build n-tier applications. To do this, you
develop COM DLL components that run on middle-tiered servers under the control
of MTS. When clients call these COM DLLs, Windows automatically routes the
requests to MTS.
Other services provided by MTS that are relevant to upgrade efforts include:
● Component transactions.
● Object brokering.
● Resource pooling.
● Just-in-time activation.
● Administration.
Upgrade Strategy
One upgrade strategy that you can use is to provide proxy COM classes that can be
accessed through interoperability, as explained in the “DCOM Applications” section
earlier in this chapter. However, this approach may not be adequate in all situations,
and you may need to re-implement MTS and COM+ services.
The .NET Framework contains classes that offer similar functionality or provide an
interface to mechanisms used by COM+. These classes are included in the
System.EnterpriseServices namespace, which provides an infrastructure for enter-
prise applications that allows .NET objects to access COM+ services. These classes
make .NET Framework objects useful for enterprise applications.
The core services employed by MTS and COM+ applications are encapsulated in the
COM+ services type library (COMSVCS.DLL).
136 Upgrading Visual Basic 6.0 Applications
Note: Most of the upgrade effort for components discussed in this section will be automatically
performed by the Visual Studio 2005 version of the Visual Basic Upgrade Wizard.6
Note: Each .NET component or namespace shown in the table should be prefixed with
System.EnterpriseServices; for example, the full name for CompensatingResourceManager is
System.EnterpriseServices.CompensatingResourceManager.
Unsupported Functionality
The COM+ services type library is used with Visual Basic and other languages
capable of building COM applications. Some members included in this library
cannot be used in Visual Basic 6.0 because they were specifically created for use with
Visual C++. An example of such a class is the CServiceConfig class. These classes
may have .NET Framework mappings, but they are unsupported by Visual Basic 6.0.
Similarly, Visual Basic 6.0 supports members that do not have semantic equivalents
in the .NET Framework. These unsupported components include functionality in the
following areas: security, context management, events management, resource loca-
tor, service configuration, and log management.
For more information about COM+ upgrades and unsupported functionality, see
Chapter 15, “Upgrading MTS and COM+ Applications.”
Summary
Understanding the possible application types that you may need to upgrade will
help you to better understand how each type should be upgraded. Each type has
features that are easy to upgrade and features that are hard to upgrade. Being aware
of potential problem areas before you begin can lessen the impact those problem
areas will have on your upgrade process.
With an understanding of the different categories of applications, you can now begin
learning the general upgrade processes and practices that are applicable to all
upgrade projects. The next chapter will give you the details you need to understand
the Visual Basic 6.0 to Visual Basic .NET upgrade process.
More Information
For more information about upgrading to ASP see “Migrating to ASP.NET: Key
Considerations” on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspnetmigrissues.asp.
For a free tool to automatically convert ASP pages to ASP.NET, see “ASP to ASP.NET
Migration Assistant” in the Microsoft ASP.NET Developer Center on MSDN:
http://msdn.microsoft.com/asp.net/migration/aspmig/aspmigasst/default.aspx.
For more information about wrappers, see “Customizing Standard Wrappers” in the
.NET Framework Developer’s Guide on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html
/cpconcustomizingstandardwrappers.asp.
138 Upgrading Visual Basic 6.0 Applications
For more information about working with assemblies, see “Working with Assem-
blies and the Global Assembly Cache” in the .NET Framework Developer’s Guide on
MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html
/cpconworkingwithassembliesglobalassemblycache.asp.
For more information about ASP.NET server controls, see “Introduction to ASP.NET
Server Controls” on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html
/vbconintroductiontowebformscontrols.asp.
Footnotes
1. Upgrading Microsoft Visual Basic 6.0 to Visual Basic .NET e-Book. Chapter 3: Upgrading options \
Selecting projects to upgrade
2. Upgrading Microsoft Visual Basic 6.0 to Visual Basic .NET e-Book. Chapter 11: Resolving issues with
language \ Making Your Code Thread-Safe
3. Desktop Applications with Microsoft Visual Basic 6.0, MCSD Training Kit.
4. Upgrading Microsoft Visual Basic 6.0 to Visual Basic .NET e-Book. Chapter 21: Upgrading Distributed
Applications \ Remoting
5. Web Applications with Microsoft Visual InterDev 6.0, MCSD Training Kit.
6. Visual Basic Upgrade Wizard Whidbey version specification, COM+ Services Type Library Migration
5
The Visual Basic Upgrade Process
This chapter provides an in-depth explanation of the technical aspects of the Micro-
soft Visual Basic 6.0 to Visual Basic .NET upgrade process. It explains each step of
the process, from initial preparation to final deployment of the application. It also
describes how to use the Visual Basic Upgrade Wizard to automate much of the
upgrade. It also discusses tasks you will have to manually perform and provides
general recommendations to achieve a successful upgrade.
Procedure Overview
The steps involved in an upgrade project can be divided in the following groups:
1. Application preparation
2. Application upgrade
3. Application testing and debugging
These task groups require specialized skills and experience. The tasks included in
each group can be executed with a certain level of parallelism, depending on the
availability and specialization of resources needed. The task groups do not define a
linear order of execution; there may be groups of tasks that are simultaneously
executed for different parts of the application.
The upgrade procedure, including inputs and outputs where applicable, is summa-
rized here:
1. Application preparation. This includes:
a. Development environment preparation.
Input: Software development installers, third party component installers
Output: A fully configured application development environment that corre-
sponds to the application to be upgraded
b. Upgrade tool preparation.
140 Upgrading Visual Basic 6.0 Applications
Application Preparation
The Visual Basic Upgrade Wizard is a tool that can automatically perform complex
tasks and help ease the upgrade process. The results obtained with this tool are
affected by the preparation applied to the original source code and how much of this
application is amenable for automated upgrade to Visual Basic .NET. This section
provides guidelines for the preparation of your application and the processing
environment to maximize the work done by this tool and have a successful upgrade.
Appropriate preparation of your application will save a considerable amount of
work in different areas, including management, development, and testing. Prepara-
tion for upgrade processes is especially important because it involves many aspects
over a long period of time. Errors in the initial stages of the process can easily
propagate and consume an extended amount of work. Additionally, a difficulty
discovered after the automated upgrade may require a part of the application to be
upgraded again, possibly producing delays in the other stages of the upgrade.
It is recommended that you begin by first preparing the upgrade development
environment. It is likely that the existing development environment is already
properly set up for building the original source code, so this preparation is relatively
inexpensive. Even when problems are identified, it is typically a matter of reinstall-
ing missing components, and correcting these types of errors should not be problem-
atic. Investing the time to correctly prepare the development environment and
correcting issues like missing components before you begin will save considerable
time and effort later in the upgrade process.
After the upgrade development environment is prepared, work can be concentrated
on preparing the source code itself. This includes examining the source code, verify-
ing the compilation, and identifying common upgrade issues.
As with any complex procedure, it is beneficial to document all the important steps
in an upgrade procedure log, including the products of each upgrade step, compo-
nent dependency relationships, and upgrade order. This document will provide you
142 Upgrading Visual Basic 6.0 Applications
with a clear view of the process, allowing you to plan and measure the effort re-
quired for the future steps of the upgrade process. It will also be useful as a base for
future upgrade projects. Figure 5.1 illustrates a sample upgrade procedure log.
Figure 5.1
Sample upgrade procedure log
System Resources
The upgrade wizard loads all global declarations of the application into memory
and keeps them there throughout the upgrade process; this is necessary to resolve
the types of members that are accessed from other modules. When a file is being
upgraded, it is loaded into memory, and all necessary transformations are applied to
it. Upon completion, the result is written to disk and the information about the
module’s local declarations is deleted from the upgrade wizard data structures.
The upgrade wizard is not an I/O intensive application; however, it makes demand-
ing usage of memory and processor resources for the storage of language structures
and the execution of transformation rules. A Visual Basic 6.0 application with 20,000
lines of code will have a peak memory usage between 160 MB to 200 MB. The
amount of memory available for the upgrade process will dramatically affect its
speed. The minimum memory size recommended for a computer on which the
upgrade wizard will be applied is 512 MB. The amount of memory should grow
according to the size and complexity of the application. Visual Basic 6.0 applications
with more than 100,000 lines of code will require a minimum of 1 GB of memory to
be upgraded. If the size of the application is millions of lines of code, a computer
with 2 to 3 GB of memory should be used. It may also be convenient to separate the
application to upgrade it in more manageable pieces.
With respect to the CPU recommendation, an Intel Pentium 4 class processor or
equivalent can process an average size application in a range of hours, assuming the
system has enough RAM.
The system’s hard drive should have enough free space to store at least three times
the size of the original application. This is necessary to generate all temporary files
and the final result of the upgrade.
External Dependencies
Typical Visual Basic 6.0 applications use third-party components. Some applications
explicitly reference external DLLs through the project settings while others dynami-
cally reference and create objects based on the components currently installed.
The upgrade of these applications requires special attention to be put on the installa-
tion and availability of these external components. All third-party components
referenced by the application to be upgraded must be installed and available. If a
component that is explicitly referenced in the project is not available in the system,
the command-line version of the upgrade tool, Visual Basic Upgrade Tool, will
display the following message and stop the execution:
Exception occurred: Could not load referenced component:
NameOfTheComponent.ocx (8.0.0)
You need to install this component before you upgrade the project.
144 Upgrading Visual Basic 6.0 Applications
It is recommended you install Visual Basic 6.0, with all referenced components,
and ensure the application compiles and runs before upgrading.
Similarly, if the application is upgraded through the use of the wizard version of the
upgrade tool (available in Visual Studio .NET), the upgrade wizard will display the
following message and stop the execution:
Upgrade failed: Exception occurred: Could not load referenced component:
NameOfTheComponent.ocx (2.0.0)
You need to install this component before you upgrade the project.
It is recommended you install Visual Basic 6.0, with all referenced components,
and ensure the application compiles and runs before upgrading.
Additionally, the following information will be shown as part of the project upgrade
log.
<Issue
Type = "Global Error"
Number = "4002"
>Could not load referenced component: NameOfTheComponent.ocx (2.0.0) You
need to install this component before you upgrade the project.It is recommended
you install VB6.0, with all referenced components, and ensure the application
compiles and runs before upgrading.</Issue>
When installing trial versions of third-party components, some of them will display
a license information dialog box each time the component is instantiated. This dialog
box will suspend the execution of the host application, such as the upgrade wizard.
If trial versions are installed for some of the components, it is recommended that
you pay attention to the messages displayed by the upgrade wizard until the pre-
processing phase starts so you can respond to all dialog boxes that are displayed by
trial version components. After the preprocessing phase starts, the upgrade wizard
can be left unattended and will continue the upgrade until the upgraded code base
is obtained.
As part of the application preparation, it is also important to make limited tests on
the upgrade of third-party components that have a complex user interface. Reduced
size applications can be written to instantiate and access the core functionality of
these components. After these applications are written, the upgrade wizard can be
used; then the code it produces can be evaluated. Special attention should be dedi-
cated to design and run time visualization and behavior of the upgraded compo-
nents. In this preliminary component test phase, the interaction between the
component, the interoperability wrapper, and Visual Basic .NET components will
be verified. For more information about interoperability, see Chapter 14, “Interop
Between Visual Basic 6 and Visual Basic .NET.” It may be useful to identify and
isolate problematic elements that will negatively affect the automated upgrade of
Chapter 5: The Visual Basic Upgrade Process 145
the full application. Most of the reasons for these problems are non-standard inter-
faces or implementations of some components. If one of these components produces
run-time errors during the execution of the upgrade wizard, one possible solution is
to remove the component and upgrade the rest of the application. The functionality
provided by this component can then be implemented again in Visual Basic .NET.
analysis focus and provides complementary views of the application and the process
of upgrading it. The tools are listed here:
● The Visual Basic 6.0 Upgrade Assessment Tool generates an extensive inventory
of the application; it pays special attention to the features that are difficult to
upgrade.
● The Visual Basic 6.0 Code Advisor recognizes features in the original application
that can be modified to have a smoother transition to Visual Basic .NET.
Although the tools for upgrade preparation make an exhaustive review of the code,
the time required to complete the process is a fraction of the full upgrade process.
This is mainly because the tools analyze the code fragments and identify certain
patterns, but the tools do not apply transformations. These preparation tools are
provided as a way to quickly estimate and improve the results that will be obtained
after the upgrade process is applied.
error that is difficult to debug. In Visual Basic .NET, only the String version of
these functions is supported.
● OLE control not upgraded. There is no equivalent for the OLE Container control
in Visual Basic .NET. When you attempt to upgrade a form that contains an OLE
Container control, any code for the OLE Container control will not be upgraded.
Instead, the control is replaced by a Label control to highlight the fact that the
OLE Container cannot be automatically upgraded.
● No Line control in Visual Basic .NET. The Line control has no direct equivalent
in Visual Basic .NET. When you attempt to upgrade a form that contains a hori-
zontal or vertical Line control, it will be replaced by a Label control. Non-vertical
and non-horizontal lines are not upgraded at all and must be manually replaced
using graphics function calls in Visual Basic .NET.
● Property/Method/Event not upgraded. The referenced Visual Basic 6.0 property,
method, or event has no direct equivalent in Visual Basic .NET. When the applica-
tion is upgraded, the corresponding line of code will be copied unmodified to the
target code. This will cause a compilation error in Visual Basic .NET.
For more information about the Visual Basic 6.0 Code Advisor, see “Visual Basic 6.0
Code Advisor” in the Microsoft Visual Basic Developer Center on MSDN.
additional tasks that have to be done to take full advantage of the new resources and
continue improving the application along its new life cycle in the new platform.
The initial source code inventory made with the assessment tool is essential for the
upgrade effort estimation. When upgrading earlier versions of applications, it is also
important to have an inventory of resources such as documentation, design dia-
grams, test cases, and specifications. These resources are helpful in the final stages of
the upgrade procedure. The original test cases are the basis for testing the upgraded
application. It is important to evaluation design diagrams and similar documenta-
tion to make decisions about the target architecture. This information also helps you
to have a high level view of the application and identify parts or functionality that
require special attention during the upgrade. Database and general design docu-
mentation can also be useful when adjusting the upgraded application. For example,
Variant variables that are used to access database fields can be re-declared with
more specific types using field data type information.
Compilation Verification
The upgrade wizard requires source code to be syntactically correct. This can be
verified by compiling the original application before the execution of the upgrade
wizard. All compilation errors produced in the original application must be cor-
rected to provide an appropriate input to the upgrade wizard. The compilation of
the original application is also useful to verify that all the components and user-
defined source code referenced by the application are available in the system. In the
case of project groups, it is important to confirm that the entire group and individual
projects can be correctly compiled. The upgrade of projects groups is explained in
detail in the next section.
When you try to open a project that references an unavailable component, the
following error message appears:
Errors during load. Refer to ‘C:\ReferenceSample\Form1.log’ for details
You can find the cause of this error message by opening the specified file. A sample
error line might look like the following:
Line 13: Class MSComctlLib.TreeView of control TreeView1 was not a loaded
control class.
To fix this compilation error and allow the upgrade wizard to upgrade this applica-
tion, it is necessary to install the component indicated in the error description. In
this example, it would be necessary to install the MSComctlLib.TreeView compo-
nent.
It is also recommended that you perform a test run of the original application on the
computer where the upgrade will take place. This test run verifies that all compo-
nents are available and that the application is producing the expected results. It is
important to take into consideration that all the run-time errors that exist in the
150 Upgrading Visual Basic 6.0 Applications
original application are likely to remain in the target application. Knowing the errors
contained in the original application provides a basis for testing and improving the
target application. For more information, see the “Testing and Debugging the
Upgraded Application” section later in this chapter.
Figure 5.2
A sample file dependency graph
This report can be used to identify independent components. In this example, the
first project included in the report, Project1.vbp, includes three files: AVICAP.bas,
MemCap.bas, and Watchman.frm. These files have different dependency relation-
ships identified in the report. The files Watchman.frm and AVICAP.bas are included
152 Upgrading Visual Basic 6.0 Applications
in the folder labeled MemCap.bas, which means that MemCap.bas depends on the
other files. Independent user-defined files depend only on third-party components
or system components, such as user32.dll. In this example report, AVICAP.bas is an
independent component because it does not depend on other user-defined files.
The first decision to make regarding component upgrade is whether the indepen-
dent components are going to be upgraded to Visual Basic .NET or are they going to
be accessed through interoperability. This decision should be based on a cost-benefit
analysis, as discussed in Chapter 2, “Practices for Successful Upgrades.” If the
components are not difficult to upgrade and they can benefit from the new .NET
features to produce a better target architecture, the components should be upgraded.
However, if the component is complex, or the benefit of upgrade is not justified by
the cost, it may be best to leave the component in Visual Basic 6.0 and use it in the
new application through interoperability techniques.
After the independent components are processed, you must treat the components
that are directly dependant on the components just upgraded in the same way. This
procedure needs to be repeated for each level of dependant components until the
entire application is processed. This method is a high-level view of the application
upgrade processing order; it can be further refined considering aspects such as the
testing phase and process efficiency and risks: these are discussed later in this
chapter.
If dependency relationships are followed in a systematic way, testing the application
in a progressive way, that is, with an increasing quantity of upgraded components,
will be facilitated. Different testing milestones can be defined in the upgrade plan
according to the dependency graph.
There is an additional consideration that needs to be taken into account when
defining the upgrade plan and component upgrade order: striking a balance be-
tween the pieces of the application that are upgraded and the testing that is applied
to the different components.
One possible strategy is to upgrade a group of the application components and
perform unit testing of the corresponding application functionality at the end of the
upgrade. After the entire application is upgraded, system testing can begin. One
advantage of this approach is that there is a greater degree of parallelism; several
components can be upgraded simultaneously with almost no coordination. The
main disadvantage is the difficulty in isolating problems during the testing phase.
This strategy is recommended for the upgrade of applications with low or mid
complexity. Upgrade complexity is determined by the language features and the size
of the application to be upgraded. For more information, see Chapter 3, “Assess-
ment and Analysis.”
Chapter 5: The Visual Basic Upgrade Process 153
In this code example, one of the Form’s controls is sent to a subroutine that sets
some initial values. When applied, the upgrade wizard produces the following code.
Sub SetObjLabel(ByRef obj As Object)
'UPGRADE_WARNING: Couldn't resolve default property of object obj.Caption.
obj.Caption = "Initial text"
End Sub
Private Sub Form1_Load(ByVal eventSender As System.Object, _
ByVal eventArgs As System.EventArgs) Handles MyBase.Load
SetObjLabel(Label1)
End Sub
As this shows, much of the code is automatically upgraded to Visual Basic .NET.
However, the line in bold font represents upgrade issues identified by the upgrade
wizard. The comment indicates what the issue is, and the code line is code that
cannot be automatically upgraded by the upgrade wizard. The code is copied
unchanged from the original code base to the upgraded code.
The problem results from late binding of the variable object to a Label object. As
stated earlier in the chapter, late binding cannot be resolved by the upgrade wizard;
it cannot determine the specific object type that is being accessed when the Caption
property is referenced. As a result, it cannot find an equivalent expression for that
property. If this code is built and executed, a run-time exception will be generated.
In most cases, the solution for this problem is to use a more specific data type for the
affected variable and replace the accessed members with the equivalent .NET mem-
bers. This is demonstrated in the following Visual Basic .NET code example.
Sub SetObjLabel(ByRef obj as System.Windows.Forms.Label)
obj.Text = "Initial text"
End Sub
Note that the UPGRADE_ISSUE comment can be removed after the correction is
made.
The subroutine SetObjLabel has a specific purpose that has been accidentally
changed with the correction to the code. In the original application, SetObjLabel
can receive any kind of control that has a Caption property. In the new version, the
subroutine can only receive Label controls. This is an important consideration that
can easily be overlooked. An alternative correction that will maintain the behavior of
Chapter 5: The Visual Basic Upgrade Process 155
Note: The ArtinSoft Visual Basic Upgrade Wizard Companion has an advanced mechanism for
automatic type deduction of undeclared variables. This mechanism performs a static analysis
of the source code based on the usage pattern of most of the Visual Basic 6.0 language
elements and the information they provide regarding the most probable data type of the
involved symbols. The relationships between symbols are also analyzed to obtain a precise
conclusion about the data type of variables, parameters, or other language elements that are
late bound. Using the upgrade wizard companion, the previous code example would have been
automatically upgraded to the code example shown here.
Depending on the additional invocations of SetObjLabel, the object parameter would have been
declared as System.Windows.Forms.Control or other control type.
For more information about the upgrade wizard companion and additional upgrade services, go
to the ArtinSoft Web site.
The following list presents the most common upgrade issues and how they can be
solved after the automated upgrade has taken place:
● Property <object>.<property> was not upgraded. This warning is generated
when a property cannot be automatically upgraded. To correct this problem, it is
necessary to use a workaround that replaces the original functionality. It may
require the reimplementation of certain application functionality.
● <objecttype> object <object> was not upgraded. This occurs when objects of
unsupported classes are declared and used. Additional development work may
be necessary to fix this problem. For more information, see Chapters 7 through
10.
● Use of Null/IsNull detected Null is not supported in Visual Basic .NET. Null is
upgraded to System.DBNull.Value and IsNull is changed to IsDBNull. This
value and function do not have the same behavior as in Visual Basic 6.0. Also,
Null propagation is no longer supported in Visual Basic .NET. The application
logic needs to be reviewed to change the usage of Null.
156 Upgrading Visual Basic 6.0 Applications
For a description of errors, warnings, and issues, see the left pane of “Visual Basic
6.0 Upgrading Reference” on MSDN.
Application Upgrade
The Visual Basic Upgrade Wizard is the primary tool for application upgrade. This
section describes the execution options that are available and how to get the most
out of the wizard.
The automated application upgrade is the middle stage in the complete upgrade
process. Before the upgrade, it is necessary to prepare and set up all necessary
components. Usually, some manual adjustments are necessary after the automated
upgrade to reach a compileable application with functional equivalence. The en-
hancement of the target application can begin after that.
There are different versions of the upgrade wizard that include different features to
further automate the upgrade result. Most of the upgrade features discussed in this
book apply to the Visual Studio .NET (also known as Visual Studio .NET 2003)
Chapter 5: The Visual Basic Upgrade Process 157
version of the upgrade wizard. The version of the upgrade wizard included in
Visual Studio 2005 has improved performance and reliability, as well as additional
upgrade capabilities, including support for additional ActiveX controls and im-
proved support for the upgrade of COM+ functionality. The ArtinSoft Visual Basic
Upgrade Wizard Companion as additional upgrade mechanisms that support
context aware upgrade of enumerations, code improvement capabilities, automatic
type deduction for Variant and Object variables, and other advancements. For more
information about this upgrade tool and additional upgrade tools and services, go to
the ArtinSoft Web site.
This section focuses on the Visual Studio .NET upgrade wizard, but when it is
applicable, the features of other versions of the upgrade wizard will be highlighted.
For more detailed information about the upgrade wizard and the automated up-
grade process, see Chapter 6, “Understanding the Visual Basic Upgrade Wizard.”
Note: This page sets the options for the upgrade. There are two available choices to select
the type of application that will be generated for the target project. EXE projects upgrade to
projects that produce an executable file, and DLL/custom control projects upgrade to
projects that produce DLLs. For standard EXE and DLL projects, the upgrade type is
determined automatically. For other types, such as EXE server projects that can act like a
hybrid of an EXE and a DLL, these projects can be upgraded to either Visual Basic .NET EXE
or DLL projects. For this example, the sample application is a standard EXE, so the EXE
option is automatically selected, and the DLL/custom projects upgrade option is unavail-
able.
5. On the Specify a Location for Your New Project page, the wizard suggests the
target directory to be called projectname.NET, where projectname is your original
project’s name. In our example, the suggested name is SumApp.NET. Click Next.
Note: If the destination directory already exists and contains files, a warning is displayed
that indicates that the output directory is not empty. The wizard will ask you to choose
another directory. If he directory does not already exist, a Warning displays that asks for
confirmation to create the directory. Click Yes to create the directory or No to specify a
different target directory. For our example, the SumApp.NET folder should not yet exist, so
click Yes to create the target directory and proceed to the next page of the wizard.
6. The Ready to Upgrade page of the wizard informs you that it is ready to perform
the upgrade. Click Next to start the upgrade.
The next page of the wizard displays information about the upgrade process status.
A Status box shows the task the upgrade wizard is currently executing and a
progress bar indicates an approximation of the time left for the task. The upgrade
can take anywhere from a minute (for a small project such as the sample application)
to several hours (for a project with hundreds of forms and classes). When the pro-
cessing is complete, the new upgraded project opens in Visual Studio .NET. Figure
5.3 illustrates a sample.
The upgraded project has a form module, Form1, that corresponds to the Visual
Basic 6.0 form module in the original project. In Solution Explorer (in the top right
corner of the IDE illustrated Figure 5.3), double-click Form1.vb to open the up-
graded form. The new form should appear similar to the original. Figure 5.4 illus-
trates this.
Chapter 5: The Visual Basic Upgrade Process 159
Figure 5.3
The sample application after applying the Visual Basic Upgrade Wizard
Figure 5.4
The upgraded form
160 Upgrading Visual Basic 6.0 Applications
To run the upgraded application, press F5. The first time an upgraded project is built
or run, you will be prompted to save the solution file. The .NET solution corre-
sponds to the root of the tree displayed in Solution Explorer. A solution file is similar
to a group file in Visual Basic 6.0. The upgraded project is contained in this solution
file. Accept the suggested name for the solution, and then press Enter to save it. The
project is then automatically built and executed. Form1 is displayed and waits for
user input. Figure 5.5 illustrates the result obtained for sample input data.
Figure 5.5
Execution of the upgraded application
Note that you should replace the directory names with the appropriate locations.
The command-line version of the upgrade tool does not have wizard pages. Further-
more, this tool does not delete any files in the destination directory. If the destina-
tion directory already exists and contains files, the command-line tool stops running
and returns an error.
It is recommended to use the command-line tool when the available memory on the
upgrade system is limited. Using this tool saves the system resources needed by
Visual Studio .NET when the upgrade tool runs. Depending on the system configu-
ration, Visual Studio .NET consumes approximately 15 MB of memory.
The tool has a verbose mode that allows a user to identify exactly what the tool is
currently doing. This is useful as a way to determine the upgrade progress of large
applications. If you use this tool while upgrading the sample application, the tool
returns the following.
C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBUpgrade>vbupgrade
C:\SumApp.vbp /Verbose
Microsoft (R) Visual Basic.NET Upgrade Tool Version 7.00.9238.0
Copyright (C) Microsoft Corp 2000-2001.
Portions copyright ArtinSoft S.A.
All rights reserved.
Initializing...
Parsing Form1.frm...
162 Upgrading Visual Basic 6.0 Applications
Note that the preceding example assumes the default installation location for Visual
Studio .NET. In this sample output, the user can see the different stages that are
involved in the upgrade of a Visual Basic 6.0 project. It is important to note that
some of the output lines may take some time to appear, sometimes several minutes,
while the tool is executing. The state of the upgrade process can be checked using
the Windows Task Manager, as discussed in the next section.
Depending on the strategy used for intermediate result testing, the following project
upgrade orders might be followed:
● First upgrade the projects that have no dependencies. If the core functionality is
upgraded first, testing can be done at different levels, starting from the core
components and including more functionality in each iteration. This approach
provides isolation of problems and can be used for upgrade projects with high
complexity and that do not require early demonstrations of upgraded functional-
ity.
● First upgrade the projects on which no other projects depend. The components at
the top of the dependency hierarchy can be upgraded first and if necessary the
application functionality can be tested using interoperability for the remaining
components. This approach can produce early demonstrations of upgraded
functionality, but it may require additional effort for the creation of
interoperability wrappers.
A mixed approach can also be used to obtain a combination of benefits.
The following example shows how to upgrade a project group using the first ap-
proach explained. The sample project group has two projects; one of them generates
a DLL that contains a class used to perform addition operations. The second project
is a front-end program that displays a form that asks the user for input and uses the
services provided by the DLL. When the project group is compiled and the gener-
ated program is executed, a form displays that asks the user for numerical values to
be added. If an incorrect value is entered, an error is raised in the DLL and the form
displays the error description. The sample application can be found on the compan-
ion CD.
To upgrade this project group when the priority is placed on the core components,
the following steps must be performed:
1. Open the Group1.vbg file group in Visual Basic 6.0.
2. Using the upgrade wizard, upgrade all projects that have no dependencies. Each
project must be processed individually, as follows:
a. In Visual Basic 6.0, observe the references associated with Project1. In the
projects window, select Project1. By default, this is at the upper-right corner of
the IDE. In the Project menu select References. The References - Project1.vbp
dialog box displays.
b. The References – Project1.vbp dialog box shows that Project1 depends on
Utilities. The Utilities project has no further dependencies, so it should be
upgraded first. For large applications, this kind of dependency analysis can be
done with the Assessment Tool File dependency graph, as explained in the
“Determine All Dependencies” section earlier in this chapter. Upgrade the
Utilities project using the upgrade wizard, as explained in the “Accessing the
Upgrade Wizard from Visual Studio .NET” section.
164 Upgrading Visual Basic 6.0 Applications
3. After Visual Basic .NET is opened, the dependant project can be upgraded and
added to the solution. On the File menu, point to Add Project, and then click
Existing Project. This opens the Add Existing Project dialog box. Click
Project1.vbp, and then click Open to start the upgrade. Accept the default up-
grade options, as described in the “Accessing the Upgrade Wizard from Visual
Studio .NET” section.
4. Replace the newly upgraded project references with the corresponding .NET
project. To do so, apply the following steps:
a. In Solution Explorer, open the Project1 project folder. Open the References
folder. Right-click Utilities, and then click Remove. This removes the reference
to the old version of Utilities.
b. To add a new reference to the new Visual Basic .NET version of the Utilities
project, right-click the References folder, and then click Add Reference. The
Add Reference dialog box displays. To view the available projects, click the
Projects tab. To add the reference, double-click Utilities, and then click OK.
Note: Now that the reference to the original Visual Basic 6.0 version of Utilities has been
replaced by the newly upgraded version, there may be differences in its interfaces and data
types. These differences will produce compilation or run-time errors in the places where
this component is accessed. When Project1 was upgraded in step 3, the upgrade wizard
considered the reference to the original version of Utilities and it was treated as an external
third-party component. An interoperability wrapper was generated and no transformations
were applied to the member declarations. Because of this, the usages of this component
inside Project1 will remain the same. The differences can arise when the Utilities library is
upgraded. The upgrade wizard will transform some of its interface declarations and there-
fore the places where the component is used must be updated. These changes include
event parameters and upgraded data types.
5. Review the accesses to Utilities inside Project1, and updated them if necessary.
For our example, the Utilities interface has not changed during the upgrade and
there are no modifications needed in Project1. However, with more complex
interfaces and data types, additional work will likely be necessary to make the
application compile.
6. The solution is now ready to be compiled, run, and tested. Set Project1 as the
startup project by right-clicking it in Solution Explorer, and then clicking Set as
StartUp Project.
7. Now that these two projects are upgraded, you can apply the corresponding
tests. After this subset of the full application functionality is tested and corrected,
a new level of functionality can be upgraded and tested on a stable base. For our
current example, there are no further projects in the group to upgrade, so the
process is complete.
Chapter 5: The Visual Basic Upgrade Process 165
Alternatively, this project can be upgraded with initial emphasis on those projects
that no other projects in the group are dependent on. To apply this strategy, the
following steps must be performed:
1. Open Visual Studio .NET.
2. Upgrade one of the projects that no other projects in the group depend on. For
this sample project group, no project depends on Project1, so it will be upgraded
first. Follow the procedure in the “Accessing the Upgrade Wizard from Visual
Studio .NET” section.
3. Next, upgrade a project that provides services to the project upgraded in step 1.
For this example, the only project that is used by Project1 is Utilities. In Visual
Basic .NET, click Add Project on the File menu, and then click Existing Project.
This opens the Add Existing Project dialog box. Click Utilities, and then click
Open. Accept the default upgrade options.
4. Project1 still references the Visual Basic 6.0 version of Utilities. This reference
must be deleted and replaced with a reference to the upgraded Visual Basic .NET
version of this project. To remove the reference, expand the Project1 references
node and remove the reference to Utilities by right-clicking it and then clicking
Remove.
5. Add a reference to the new Utilities project: Right-click Project1 References, and
then click Add Reference. In the Add Reference dialog box, click the Projects
tab, double-click Utilities, and then click OK.
6. See step 5 in the previous procedure for additional considerations when replacing
the Utilities reference from the Visual Basic 6.0 version of the component to the
Visual Basic .NET version. The same issues are possible despite a change in the
order of component upgrade.
7. The solution is ready to be compiled, run, and tested. Note that after step 2,
Project1 may be tested using the non-upgraded version of Utilities through
interoperability.
Although the example used to illustrate these two procedures was relatively small,
keep in mind that either of these upgrade approaches can be applied to project
groups composed of many projects. The approach you choose to apply should be
based on careful analysis of the components and their dependencies. A project group
containing many components with no dependencies will likely benefit from the
application of the first upgrade approach presented. Alternatively, a project group
with many components that have no other components dependent on them may
benefit from the second approach.
166 Upgrading Visual Basic 6.0 Applications
The same upgrade engine is launched when the upgrade wizard is accessed in
Visual Studio .NET, but in this case, the only process that will be launched is
VBUD.exe.
The Windows Task Manager displays the two upgrade processes launched by the
command-line version of the upgrade tool.
The upgrade wizard for the 2003 version of Visual Studio .NET processes source
code files one by one and stores each result as a temporary file. After all files are
processed in that way, the final Visual Basic .NET source code is written to the
output directory. This is the final result delivered to the user. If there was a problem
during the upgrade of a file and the upgrade tool has to terminate execution, any
previous temporary results will be lost and no final Visual Basic .NET results will be
obtained. To avoid this situation, the Visual Basic 2005 version of the upgrade
wizard and the Visual Basic Upgrade Wizard Companion from ArtinSoft produce
the final upgrade results on a file-by-file basis. After a file is processed, the final
source code is written and the target project and solution files are updated. This
allows the user to use the results, even if a fatal error occurred during the upgrade of
another file.
Figure 5.6
The Windows Task Manager Performance display in a typical “thrashing” scenario
● Incorrect references. When an application has more than one project to be up-
graded, you may choose to upgrade one project at a time. You can make some
source code reorganization according to upgrade priority or other factors. If a
reference to a user project or a third-party component is accidentally changed to
another reference during this reorganization, the upgrade wizard will not be able
to obtain all the necessary information about members and data types. This will
generate warnings about default property extraction in all places where members
of these components are used, because none of these members will be automati-
cally upgraded by the upgrade wizard. If this happens, the corresponding refer-
ence and accesses to the elements contained in it will have to be reviewed.
● Trial version of third-party components. The upgrade wizard loads all third-
party components referenced in the project. Some trial version components
display a license dialog box and wait for user input whenever the components is
instantiated. This will cause the upgrade process to stop until the dialog box is
closed. You should pay attention to these dialog boxes to allow the upgrade
process to continue.
● Upgrade wizard exceptions. It is an unusual scenario, but when a file is being
processed by the upgrade wizard, it may be possible for the tool to encounter a
fatal problem. For example, third-party components with a nonstandard interface
or other conditions will produce an exception. In this case, the upgrade tool will
terminate execution. The first step to solve this problem is to isolate the file and
168 Upgrading Visual Basic 6.0 Applications
source code that is producing the exception. After this is done, the source code
can be commented. After the problematic code is removed, the upgrade process
can be started again. You may want to report these types of exceptions to
newsgroups so that other developers can avoid them. Some suggested
newsgroups are microsoft.public.dotnet.languages.vb.upgrade and
microsoft.public.dotnet.languages.visualbasic.migration.
Being aware of and planning ahead for known exceptions can help you to have a
smoother upgrade.
To correct this problem, apply the techniques presented in the “Reviewing the
Upgrade Wizard Report” section earlier in this chapter.
The following sections present additional upgrade issues that are detected by the
upgrade wizard and require user intervention to be corrected.
Problems with As Any Parameter Type
When external DLL functions are accessed in Visual Basic 6.0, it is often necessary to
include As Any parameters in the corresponding function parameter declaration.
This data type is no longer supported in Visual Basic .NET. The problem caused by
this change is demonstrated through the following example Visual Basic 6.0 code.
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As _
Integer, ByRef lpvParam As Any, ByVal fuWinIni As Integer) As Integer
The latter code will produce a compilation error in Visual Basic .NET caused by the
usage of an unknown As Any data type. To correct this problem, it is necessary to
investigate the specification of the external function SystemParametersInfo. This
function gets the value of system parameters based on the uAction parameter and
stores the result in the lpvParam parameter. The lpvParam parameter data type
must be changed to a specific data type according to the usage of the function in the
source code. In this case, the system parameter to be obtained is the keyboard auto-
repeat delay, and the expected result is a short type. To fix this problem, change the
As Any data type to As Short.
For more information about correcting this error, see Chapter 13, “Working with the
Windows API.”
Changes to Properties of Commonly Used Objects
The following source code compiles and runs perfectly in Visual Basic 6.0; however,
when it is upgraded to Visual Basic .NET, a compilation error result because of an
unsupported property, as shown here.
' List1 is a list box that is embedded in the current Form
List1.AddItem "Hello"
List1.ListIndex = List1.NewIndex
After the upgrade wizard is applied to the code, the following code results.
' List1 is a list box that is embedded in the current Form
List1.Items.Add("Hello")
' UPGRADE_ISSUE: list box property List1.NewIndex was not upgraded.
List1.SelectedIndex = List1.NewIndex
Chapter 5: The Visual Basic Upgrade Process 171
This code results in a compilation error in Visual Basic .NET because the NewIndex
property is used to retrieve the index of the item most recently added to a ListBox
control. However, the value of NewIndex cannot always be determined in the
upgraded code. This error can be corrected by saving the return value of the Add
method, which is the index of the newly added item. This is demonstrated in the
following code example, with changes highlighted in bold.
' List1 is a ListBox that is embedded in the current Form
Dim NewIndex As Integer
NewIndex = List1.Items.Add("Hello")
List1.SelectedIndex = NewIndex
The On … GoSub construct is no longer supported in Visual Basic .NET. The up-
graded code produced by the upgrade wizard causes a compilation error. However,
the code can corrected by removing the problematic construct, as demonstrated
here.
Function Decide(ByRef v As Short) As String
If v = 1 Then
Decide = "case1"
ElseIf v = 2 Then
Decide = "case2"
ElseIf v = 3 Then
Decide = "case3"
End If
End Function
The issues presented in this section have shown the most common manual changes
you will have to apply to code produced by the upgrade wizard. However, this is
not a comprehensive list. For information about other upgrade issues and the
manual corrections you will have to apply to fix them, see Chapters 7 through 13.
Chapter 5: The Visual Basic Upgrade Process 173