Thinking, Learning, Questioning
Migrating From VB6 to .NET
There is a ton of stuff/applications out there which have been written in VB6 and which are still around in many organisations. Previously when I was working with Java, I used to deride people who were writing in VB6 for reasons such as no object oriented paradigm and that it ran in a pseudo interpreted mode. It was however easy to create GUI applications on the Windows Operating System and allowed an easy method for linking to COM/DLLs.
As we’ve just recently migrated a business critical application for a client, I thought I would share some of our learning. Migration of an existing piece of code is never an easy task and even more so when there is no documentation provided with it and has been developed by a one man band outfit who is no longer interested in supporting it. We are talking the type of code that no self respecting .NET developer would want to touch in that state.
There are a number options for legacy VB6 applications, which are :
- Rewrite the application in .NET from scratch
- Migrate the application using the Visual Studio 2005 Migration Wizard
- Use the Interop Forms Toolkit to add .NET functionality running within a VB6 process for a gradual migration process
We used the Migration Wizard in Visual Studio 2005 which takes the VB6 code and attempts to automatically upgrade the project to VB.NET. After the upgrade has taken place you would attempt to compile the new project. The likelihood is that there will be many compile time errors which would have to be individually resolved. This is a painstaking process and certainly not glamorous.
VB6 and VB.NET only have the “VB” bit in common, they are essentially completely different programming languages. VB6 is unmanaged code and loosely typed, whereas VB.NET is managed code and strongly typed. Therefore at this stage significant portions of the application may require to be rewritten. Migrating to .NET is a good choice as this is a great platform to develop for and Visual Studio is still probably the best Development Environment around.
Once you have got a clean compilation and subsequently resolved any linking issues to DLLs/COM components you can then attempt to run it. This is the point at which you will hit the runtime errors and where you will discover that linking to some of your precompiled DLLs no longer work. This is also where you find that the User Interface looks rubbish because the Migration Wizard has converted into a Form Control which is not like the original. Also you must remember that there is not a one-to-one mapping between the VB6 Controls and VB.NET Controls, so you’ll probably be doing more rewriting here.
Microsoft has a good site for VB6 Resources and Migration Guides.
You can also find the support statements for VB6 here, which is essentially out of mainstream/extended support.
about 7 months ago
Nice post. Several years ago I helped my company migrate several 100 VBPs (about 1M LOC) to C# along with replacing COM components and restructuring the code to fit our .NET coding standards. It require alot of redesign and retooling work. However, we did very little of the C# coding/fixing by hand.
We used a translation tool that could be improved and customized. We invested time in making the tool produce translations that were more correct and more conformant to our standards. Once this “tuning” was done, the automatic conversions were much better and we could move the VB6 to C# incrementally along with other maintenance work. I subsequently left that job to start a company to bring this agile migration methodology to the VB6 and ASP community. We have recently productized our solution. Please see http://www.greatmigrations.com for more.
about 7 months ago
The Upgrade Wizard is a good start, but there are other third party tools that can do a much better job. I’ve tried some of them, but the problem in some cases is that you’re left with a huge proprietary runtime, and even though this approach might speed the conversion process, who wants to be tied to another third party? But I’ve found also that artinsoft, the company who built the Upgrade Wizard for Microsoft years ago, now has a more powerful tool, called the visual basic upgrade companion. I only converted a couple of small applications, both to VB.NET and C#, but liked the results very much. There’s a free trial available for download if you want to try it yourself.
about 1 month ago
There are no references available about migration and its associated challenges for COM and COM+.
Hence it will be great if any one could provide such kind of information.