By Nellaiappan L | March 24th, 2021 |
Converting VB6 code to VB.NET is not a simple process that can be executed easily even when using automation tools. Several automation utilities are available in the market, with Microsoft itself being shipped with a Visual Basic Upgrade Wizard. One of the major changes in VB6 is in the Common Language Runtime (CLR) a new programming model. To reap the maximum benefit out of the new features and structures of VB.NET, it is advisable to rewrite major sections of the application rather than simply using an automated migration process. Since this is a tedious process you can use VB.NET’s Upgrade Wizard that automatically converts the syntaxes, which helps getting the initial work done. But after using the Wizard you will be faced with other problems and errors during compilation. These are fully handled properly by the Wizard. During migration, you will have to rewrite and rearchitect the codes to take maximum advantage of VB.NET’s new tools and capabilities.
.NET migration is a complex process that requires strict adherence to the features and syntactical aspects of the programming language. Here are some of the essential steps that need to be considered while migrating from VB6 to VB.NET.
Perform a thorough assessment of the application to be upgraded. You can manually document the existing system functionalities, though it may be a tedious process. Use an assessment tool to analyze the VB6 application to understand issues and estimate the approximate cost and effort. The tools are helpful in generating reports from which the migrations team can be provided an idea about the future actions that will be required during the full migrations project. The tools can help predict where the team will need to code new libraries, new functionalities, and more.
Prepare a project plan, determine scope and migration requirements by revealing the maximum information about both the legacy and new application. Create functional requirements for the new framework and application. Get all the tools, assemble a team, and ensure everyone is working together towards a common set of deliverables.
Develop a migration strategy after brainstorming and documenting the application requirements. First, you need to get the VB6 application into the new .NET platform with the existing functionality. Then perform incremental changes to incorporate new functions and features. There are several ways to approach the migration, and more than one of them may be used in various forms within the various stages of your migration project. It is better to plan ahead but also remain flexible enough to address the ever-changing needs of the business.
After running an automated migration, the quality of the generated code needs to be improved. This involves removing duplicated code, upgrading problematic syntax and controls, and fixing data declarations. The automation process produces a code with the same code quality as the previous code. Automated changes are often cosmetic, and the changes may also be incomplete requiring manual intervention.
It is essential to rewrite critical application logic to fit the .NET framework and those that have not been properly converted during automation. One approach is you can continue writing new code in VB.NET leaving the bulk of the existing code in VB6 as there is good interoperability between VB6 COM components and VB.NET components.
This involves creating a SQL Server or database and importing data and resizing the database structure. Normalization and optimization of the data ensures better performance.
Compiling the project provides a list of compilation and runtime errors that will need to be analyzed and fixed by your team following an iterative process.
Bugs can be tracked using various source code analyzers that helps identify duplicate codes and fix data declarations. Bug fixing and development needs to happen at arm’s length as new codes are converted. Testing needs to be done and passed by a separate group then those who did the development.
Upgraded applications will be subjected to different levels of testing throughout the process. This ensures the reliability and correctness of the application. The quality assurance activities will be parallel to development.
Finally deploy to the application server and verify the checklist of all the components and functionalities in the application tally.
Another aspect that developers should keep in mind during VB6 to .NET migration, is the difference in the procedure by which objects are cleared from memory. In VB6, object instances are cleared using COM reference counting mechanism. While in VB.NET, the job of clearing unreferenced objects is done by garbage collector. Garbage collection helps in establishing a compact memory in use. Developers utilize the method Collect in GC class to perform garbage collection. However, calling the garbage collector explicitly leads to suspension of all threads before triggering the garbage collection that lead to performance issues. So the implicit method invoke is always recommended.
Migrating VB6 to .NET is definitely the way to go with rapidly changing programming landscape. Migration puts forth some challenges that can be overcome with automation tools, source code analyzers and proper planning by only upgrading sections relevant from a business point of view. Here at Macrosoft we have a proven track record of successfully migrating business-critical applications, which are executed by a dedicated team of developers experienced in both VB6 and VB.NET environments.
For more information related to .NET migration and services, continue reading our blogs.