In this topic
About migrating from VB6 to VB .NET
This topic discusses the general migration process, which includes the following phases—plan, prepare, upgrade, test, deploy, and advance. See the following illustration:
Plan
In the planning phase, developers define the goals of the migration process and evaluate the risks, and estimate the costs for the migration. For larger migration projects, it might take a few weeks to fully understand all of the involved migration issues. It is helpful for migration developers to be well versed in the VB6 and COM technologies as well as understanding the .NET Framework capabilities. When developers are comfortable with the migration strategy and issues, it is estimated that 7,000 to 10,000 lines of code can be converted per week. At a minimum, developers need two computers to perform a migration—one with ArcGIS 9.3 and VB6 installed and one with ArcGIS 10 and Visual Studio installed.
Prepare
During the preparation phase, developers delve into the VB6 code to fully understand what is happening in the project. Modifications to the VB6 code base might be necessary to ensure a smooth upgrade to VB .NET.
Developers should make note of the exact VB6 references used in the project as the Visual Basic Upgrade Wizard (see the Upgrade phase) will not only add all references used in the VB6 project to the VB .NET project, but also any detected dependency libraries, whether or not any calls were made to types used in the dependency libraries. Noting which VB6 references are used helps developers identify which extraneous library references were added to the VB .NET project by the upgrade wizard and therefore, can be safely removed to keep .NET customization with a lean footprint.
Developers should also ensure that best practices were used in the VB6 project to modularize the code as much as possible. The Visual Basic Upgrade Wizard performs more reliably if code is modularized. This means that in VB6 code, avoid using global variables and instead, use Functions and Subs with parameterized functions wherever possible. Finally, the business logic of the VB6 application should be separated from being directly in the various Events procedures (for example, OnClick, MouseDown, and so on) of the application. The business logic should be in its own modularized and parameterized Functions and Subs.
Set the Option Strict statement to "On" in VB6 applications and use the Option Explicit statement. VB6 developers should use early binding (declaring variables of a specific type rather than as an object) and zero-bound arrays (do not use Option Base 1) in the code. Avoid the use of default properties on types and controls. Additionally, avoid the use of keywords not supported in VB .NET (such as, GoSub, VarPtr, ObjPtr, and StrPtr).
Upgrade
In the upgrade phase, developers use the Visual Basic Upgrade Wizard to auto-translate code from the VB6 to VB .NET language. During this phase, ArcGIS Engine developers should also use the ArcGIS Code Migration tool to update code written in ArcGIS 9.3 to 10. Once the auto-translation wizards have completed, developers can fix compile errors and warning messages. Do not go directly to the upgrade phase, and skip the plan and prepare phases.
To access the Visual Basic Upgrade Wizard, in Visual Studio click File, Open, then Project/Solution. Locate and open the VB6 project. A series of wizard dialog boxes open to navigate through. The following screen shot shows the first wizard dialog box:
At this point, developers can fix compile errors and warnings that are in the VB .NET project. The auto-translator conversion process is not 100 percent automated (there might be errors in your new VB .NET project). The upgrade wizard creates an upgrade report. Review this report and correct all the listed issues. In addition to the issues listed in the report, you might find other errors in your upgraded code that cannot be caught by an automated process. For this reason, review each line of code to ensure that your new project performs correctly.
For more information about fixing the various compile errors and warnings when migrating from VB6 to VB .NET, see the following on Microsoft's Web site:
- Upgrading Visual Basic 6.0 Applications to Visual Basic .NET and Visual Basic 2005
- Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET
When you have finished progressing through the upgrade wizard and fixed as many errors as possible, use the ArcGIS Code Migration Analyzer tool provided with the ArcObjects .NET software development kit (SDK) to provide guidance on changes developers should make to their upgraded source code, to make their pre ArcGIS 10 project work in the ArcGIS 10 architecture. The ArcGIS Code Migration Analyzer tool adds the file, ArcGISCodeMirator_Log.txt, to the Visual Studio project. It provides guidance for changes that developers will manually need to make to their projects. The ArcGIS Code Migration Analyzer tool performs many checks on the project including the following:
- Identify legacy assembly .dll files that should be removed and recommend new assembly .dll files that serve as a replacement.
- For stand-alone applications (.exe files), recommend the use of the new ESRI.ArcGIS.Runtime.Bind function that is a new requirement for ArcGIS 10.
- Identify Windows registry keys that have changed and recommend new alternatives.
- Identify any ArcObjects types (such as, interface, class, enumerations, and so on) that have been removed and recommend new options.
- Identify any potential platform target central processing unit (CPU) conflicts for ArcGIS 10.
- Search for the Version Specific property on ESRI assemblies that are set to false and recommend the setting be set to true.
To access the ArcGIS Code Migration Analyzer tool, in Visual Studio click Tools, then ArcGIS Code Migration Analyzer. The ArcGIS Code Migration Analyzer dialog box appears. See the following screen shot:
ESRI has also performed extensive testing on migrating from VB6 to VB .NET and has discovered several important issues that could confuse ArcGIS developers. For more information, see the following:
- Fixing OLE_HANDLE values of Bitmap properties for commands, tools, and dockable windows
- esriSystem.IUID values translate incorrectly
- Loading Windows forms has different behavior
- Setting default Object properties to IColor is problematic
- stdole library not added to migrated project
- Command and Tool Bitmap property expects hWnd to display bitmaps
- Registering COM interop
Additionally, there are new issues that are unique to ArcObjects migration from ArcGIS 9.3 to ArcGIS 10 that developers need to be aware of. For more information, see Migrating ArcGIS 9.3 Desktop and Engine custom components to ArcGIS 10 and How to migrate ArcGIS 9.3 Desktop and Engine stand-alone applications to ArcGIS 10.
Test
The testing phase ensures that code that has been migrated from VB6 to VB .NET works the same in both languages (this is also known as testing for functional equivalence). It is important to thoroughly test a migrated application and not rely on just a compile without errors or warnings for verification of a successful migration.
The behavior of many of the Microsoft controls is different in VB6 than in VB .NET. In some circumstances, an equivalent VB .NET control does not exist that used to be in VB6 (for example, ImageCombo, Shape control, Line control, and so on).
In addition to migrating development languages, these applications are also migrating a different version of ArcGIS, where some changes might have been made that break the business logic of your application. The only way to catch these changes is to be aware of what is new in this release and test to ensure these changes do not affect your application. For more information, see What's new for developers at 10?.
Deploy
The deployment phase rolls out the migrated application onto the end-user's system. For developers, this step might be temporarily delayed if the migrated application is going to the advance phase. There are several options for deploying an ArcGIS customization on .NET systems. For more information, see the following:
Advance
The advancement phase is optional. It is for developers who want to make significant changes to the code base after the auto-translation occurs when converting from VB6 to VB .NET, and the compile errors and warning issues have been addressed. The advance phase covers situations like the following:
- Adding additional functionality to the customization.
- Converting to another language besides VB .NET (for example, C#).
- Fixing parts of the customization that do not have functional equivalence between VB6 and VB .NET.
Many developers will be interested in changing the structure of how the migrated customization works. For valuable resources when advancing code from VB6 to VB .NET, see the following:
- Advancing error handling from VB6 to VB.NET
- Advancing switching interfaces from VB6 to VB.NET
- Advancing event handling from VB6 to VB.NET
- Advancing common function calls from VB6 to VB.NET
See Also:
Migrating from VB6 to VB.NETDevelopment licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
Engine Developer Kit | Engine |