Preparing to Migrate an Add-in

 < Free Open Study > 


"Success supposes endeavour".

--Jane Austen

In Chapter 1, I said that VB 6.0 add-ins are, for all practical purposes, broken by .NET. There is good news and bad news in that statement. The good news is that you have a more powerful model to upgrade to. The bad news is that VB 6.0 compiled add-ins that implement IDTExtensibility will not load in the .NET IDE. The message shown in Figure 13-1 displays when you try to connect to the add-in. Although the message does not bother to tell you the name of the interface that is unsupported, my educated guess is that it is the IDTExtensibility (VB 6.0 automation) interface, simply because that is the only interface implemented in the add-in.

click to expand
Figure 13-1: Error message encountered when trying to load a VB 6.0 add-in


I could be wrong about this being the problem. However, the terms "VBIDE" and "IDTExtensibility" do not appear in MSDN. From that standpoint, I am left to believe that the interface is not supported by Visual Studio .NET.

Before I go further into the subject of upgrading your VB 6.0 add-ins, there is some additional disappointing news. If you run your old VB 6.0 add-ins through the Migration Wizard, you probably will find that not all of your code upgrades successfully. The misleading thing is that once the upgraded add-in has been brought into Visual Studio .NET, none of the extensibility object references will be marked in error. The upgrade tool recognizes that your program is an add-in and adds a COM interoperability reference to your project for the VBIDE.DLL, which is the automation DLL for VB 6.0.

This would imply that you could still use the automation object that you used in VB 6.0 if you do not have to have any of the new functionality of the new .NET automation object. I say this with reservations, however, because this does not mean that you will be able to use your add-ins without modification, even if they make it through the Migration Wizard fairly unscathed.

Having run the upgrade tool on your add-in, you are faced with several tasks. First, you must clean up any errors unresolved by the upgrade tool. Second, you must register the add-in manually using Regasm.exe. Finally, you have to make the entries in the registry so that the Add-in Manager will list your add-in in its dialog box. Having performed these tasks, you would expect that your add-in would now load. That's where the disappointment comes—it will not. In fact, after you upgrade a very simple add-in that basically does nothing except add an Office CommandBar menu, the same message shown in Figure 13-1 will display. You are once again met with the message "No such interface supported".


Having worked on this problem for several days with no success, I am left with the conclusion that the upgrade tool thinks that IDTExtensibility is supported, but Visual Studio .NET does not. It would be extremely helpful if Microsoft either corrected this situation or, if it is a matter of "user error", provided documentation as to how it is supposed to work.

Assuming that you will not be able to use IDTExtensibility, you can still get a lot of mileage out of running your VB 6.0 add-ins through the Migration Wizard. Here again, the amount of usability that you retain in migrating any type of application, especially add-ins, will be proportional to the applicability of the VB 6.0 functionality upgrading to .NET. For example, there has been a paradigm switch in the way the Windows Forms Designer works. A large percentage of the properties on forms, controls, and their respective events have changed. Therefore, if your VB 6.0 add-in was manipulating properties on a VB 6.0 form and/or some of the controls on the form, the probability is extremely high that the code will require a rewrite in .NET, for two reasons. First, the extensibility model has changed. Second, the properties that you are trying to manipulate have changed. That may or may not be catastrophic to your add-in functionality. In some cases, you may simply need to change the names of the properties that you were manipulating. In other cases, a property may no longer exist. However, it may have been replaced by some other property. There are many more properties in .NET forms than there were in VB 6.0 forms.

In this chapter, I take you through the process of migrating a VB 6.0 add-in. It is not a large one, but I discuss some of the problems that I have encountered in migrating some larger and more extensive add-ins. I tell you some things you can do before migrating your application, and I point out the most obvious areas (not individual code) that will not upgrade. You can get more detailed information by searching MSDN on the subject of migrating applications.

 < Free Open Study > 

Writing Add-Ins for Visual Studio  .NET
Writing Add-Ins for Visual Studio .NET
ISBN: 1590590260
EAN: 2147483647
Year: 2002
Pages: 172
Authors: Les Smith © 2008-2017.
If you may any questions please contact us: