As mentioned in a previous post, developing with VB6 with ArcGIS will no longer be supported at ArcGIS 9.4.  The good news is that ArcGIS 9.x developers have a number of options when it comes time to migrating existing VB6 projects to .NET.  


One of the easiest methods is to use the Visual Studio Upgrade/Conversion Wizard.  Check out the video to see exactly how it works.  As you’ll see, the wizard is easy to use, but as you can imagine, it does not upgrade everything perfectly.  So before jumping in, be sure to review this document on MSDN, and here are a few other things to consider:

Pros

1.       The wizard is “relatively” fast and easy to use.  1-2 min for our small test project.


 


2.       An Upgrade Report is created automatically so you can easily hunt down the items that didn’t automatically convert.  Just look for “UPGRADE_ISSUE” comments in the code.


 


3.       The .NET compiler will give you warnings and errors that were ignored in VB6 such as unused variable declarations and so on.  This should help improve the quality of your code.

Cons

1.       Not all ESRI.ArcGIS assemblies and types are mapped correctly and you need to deal with these issues manually.  For example, the ESRI.ArcGIS.esriSystem.OLE_HANDLE.


 


2.       The new project will likely reference VB.NET-specific compatibility assemblies (e.g. Microsoft.VisualBasic.dll) to map to the old VB6 types.  This may or may not be desirable if you plan on moving the code to C# or if you want to just use the core .NET assemblies and types.  Performance can be affected as well.


 


3.       Some .NET controls don’t map 100% to their VB6 counterpart, and code changes are required.  E.g. CommonDialog::xxx.


 


4.       You may want to consider using Private or Public declares instead of Dim.


 


5.       You need to set “Register for COM Interop” in the new project to register the classes as COM components.


 


6.       It only converts to VB6 code to VB.NET, not C#.

 

The last thing to consider is that the wizard simply performs a raw conversion of the interfaces and classes as they are implemented in VB6.  It has no way of knowing that there are a number of ArcGIS .NET base classes that can be used to accomplish the same task.  Therefore, if you use the wizard, and if your VB6 code implements ICommand, ITool, IToolbar and IExtension, you should consider removing the class that is created, and re-implement it with the ArcGIS base classes.  We’ll see this in a future How To… post.

 

Regardless of the cons here, it’s obvious that the Upgrade Wizard isn’t perfect but it does provide a fast and easy way to get you through the migration process.  

   

Special thanks to Rob Burke for contributing the video that illustrates how to get this done!


Tagged with:  

2 Responses to How To… Developer Series: Using the Visual Studio 2008 Upgrade Wizard

  1. theavey says:

    Are there any extension examples. I have only seen ICommand examples?

  2. alaframboise says:

    Hi there. We didn’t put together any examples of converting IExtension, but it’s a pretty straight forward interface with only three members.

    This part of the help might point you in the right direction.

    http://resources.esri.com/help/9.3/ArcGISDesktop/dotnet/concepts_start.htm

    Plus, there’s a sample here that might help as well.

    http://resources.esri.com/help/9.3/ArcGISDesktop/dotnet/f90f78a3-6dcc-4a17-8e22-74c25c93eb4a.htm

    Hope this helps.

    AL

    EDN Team

Leave a Reply