Home > Articles > Programming > Windows Programming

This chapter is from the book

Upgrade Wizard in Visual Studio .NET

Visual Studio .NET is the new development environment for developing Microsoft .NET applications. Because Visual Basic has undergone lots of changes to its syntax and many new features have been added to the language, the Visual Studio .NET IDE contains an upgrade wizard, which helps in upgrading Visual Basic applications to Visual Basic .NET. This section covers details about the upgrade wizard.

Upgrading a Visual Basic 6.0 Project

The upgrade wizard is used to upgrade Visual Basic 6.0 applications into a Visual Basic .NET application. Applications that have been developed using earlier versions of Visual Basic (that is, versions lower than Visual Basic 6.0), have to be upgraded to Visual Basic 6.0 before using the upgrade wizard. The most important thing about this upgrade wizard is that it leaves the original Visual Basic 6.0 project untouched and creates a new Visual Basic .NET project.

If a Visual Basic 6.0 application is opened in Visual Studio .NET, the upgrade wizard is invoked automatically as seen in Figure 3-2. As shown, the upgrade wizard creates a new Visual Basic .NET project, which will be the upgraded version of the Visual Basic application being opened. The wizard will copy each file from the original project into the new project and make the necessary modifications to make it a Visual Basic .NET application.

03fig02.jpgFigure 3-2. First screen when the upgrade wizard is opened in Visual Studio .NET.


On clicking Next, the screen shown in Figure 3-3 is displayed. As shown, the upgrade wizard automatically detects the type of the Visual Basic application to be converted. If the application is a DLL or custom library, the checkbox Generate default interfaces for all public classes is enabled. If this checkbox is not checked, interfaces will be generated only for those classes that have been implemented by other classes in project. If the checkbox is checked, interfaces are generated for all the classes whether they have been implemented by other classes or not.

03fig03.gifFigure 3-3. Selecting the project type for the upgrade wizard.


On clicking Next, we get Figure 3-4. In this screen, the location of the Visual Basic .NET project can be specified. If the directory does not exist, it is created and a Visual Basic .NET project is created in the new directory. On clicking Next, the screen obtained is as shown in Figure 3-5. On clicking Next in the following screen the update process is started as shown in Figure 3-6.

03fig04.gifFigure 3-4. Specifying location for creating the upgraded Visual Basic .NET application.


03fig05.gifFigure 3-5. Ready to Upgrade Screen.


03fig06.gifFigure 3-6. Upgrade Engine is invoked.


Once the upgrade wizard has upgraded the application, the tool prepares an upgrade report that lists all the steps that the wizard has completed and what steps are remaining for the developer to complete the upgrade.

Upgrade Report

When the upgrade tool has finished upgrading the application, it prepares an upgrade report that can be seen in the solution explorer window of Visual Studio .NET. The file name is _UpgradeReport.htm. Double-click the file name so that it will be opened in the Visual Studio .NET browser window. Figure 3-7 shows the upgrade report.

03fig07.jpgFigure 3-7. Upgrade report generated by the upgrade wizard in Visual Studio .NET.


As seen in Figure 3-7, the upgrade report shows the upgrade details. Specifically it shows the new file name (in the Visual Basic .NET project), the old file name (in Visual Basic), and the file type (whether is a form, a class, or so on). It also shows the status of the upgrade (i.e., whether the file was upgraded or whether it had any errors or warnings) and gives the error and warning counts for individual files. Clicking on the + sign next to the file name will give the details of the file, as shown in Figure 3-8. The settings used during the upgrade process are also listed in the upgrade report and a log file is created. Figure 3-8 shows the issues (if any) for a specific file.

03fig08.gifFigure 3-8. Upgrade issues for a specified file.

Now let us look at an example of the upgrade wizard in which there were errors and warnings during the upgrade process. Figure 3-9 shows the screen. As shown, when Visual Basic 6.0 was upgraded, there were a few errors. The report shows the upgrade issues. Specifically the report lists the severity of the error, the location of the error, and the object, and the property on which the error occurred and gives a description of the error.

03fig09.jpgFigure 3-9. Upgrade report showing a list of files with errors and warnings.

COMPILE ERRORS

Compile errors occur when the upgraded code cannot be compiled in Visual Basic .NET because some property or object is not supported in Microsoft .NET Framework. Any issues that fall under compile errors in an upgrade report need to be corrected by the developer; otherwise the application cannot be executed. The upgrade wizard will insert upgrade issues in case of compile errors.

Following are some of the cases that cause compilation errors during the upgrade:

  • The Visual Basic 6.0 application uses ListIndex property of ListBox or ComboBox control.

  • The Visual Basic 6.0 application uses DrawStyle property of PictureBox control.

  • Functions like VarPtr, StrPtr, ObjPtr, MidB, and ChrB and statements like GoSub have been used in the Visual Basic 6.0 application.

  • The Visual Basic 6.0 application is trying to set a read-only property of particular control.

DESIGN ERRORS

When design errors occur, the upgraded code can be compiled and executed in Visual Basic .NET. This error indicates that a property that can be set at design time in Visual Basic 6.0 cannot be set then in Visual Basic .NET. Design errors generally apply to forms and controls. Some causes for design errors are as follows:

  • A particular property of one control has a new behavior in Visual Basic .NET. Following are some of the cases that cause these errors:

    • TextBox.TextLength property

    • Form.Picture property

    • Form.Unload event

    • ComboBox.Change event

  • Raster fonts are used on the Visual Basic form.

  • A particular property or method of Visual Basic 6.0 has been removed in Visual Basic .NET

Warnings

The upgraded code can be compiled and executed in Visual Basic .NET. The upgrade wizard issues a warning when some property that could be set in Visual Basic exhibits a changed behavior in Visual Basic .NET. Any warnings should be examined to make sure that they do not affect application behavior. Following are some of the cases when the upgrade wizard issues warnings:

  • If arrays have been declared with New keyword.

  • If an array doesn't have a zero lower bound.

  • If Visual Basic application has used Null or IsNull because Null is not supported in Visual Basic .NET.

  • In Visual Basic .NET some of the properties enumerators of Visual Basic 6.0 have changed. Therefore, an upgrade wizard shows a warning that the value for particular property could not be resolved.

There are instances when no error is listed in the upgrade report, but the application fails to execute in the Microsoft .NET environment. However, such cases are very infrequent.

As Figure 3-9 indicates, the descriptions of the errors and warning are actually hyperlinks, which provide links to the specified materials in Microsoft .NET documentation. For example, clicking on the third description in the figure will lead to the screen shown in Figure 3-10. This screen gives an indication of why there was an error in upgrading the Visual Basic application to Visual Basic .NET. It also gives a pointer and a detailed explanation to the developer on how to solve the error.

03fig10.jpgFigure 3-10. MSDN documentation for the specified error/warning.

In addition to the upgrade report, the wizard also puts comments in the upgraded code to indicate that there were issues. The following code snippet shows a Visual Basic .NET code that was generated by the upgrade wizard:

   Private Sub Form1_Click(ByVal eventSender As_ 

      System.Object, ByVal eventArgs As System.EventArgs)_ 

         Handles MyBase.Click 

   'UPGRADE_ISSUE: PictureBox property Picture1.FillColor 
       was not upgraded. Click for more: 'ms-help://MS.VSCC 
          /commoner/redir/redirect.htm?keyword="vbup2064"' 

      Picture1.FillColor = System.Drawing.ColorTranslator._ 
         ToOle (System.Drawing.Color.Red) 

'UPGRADE_ISSUE: PictureBox property Picture1.FillStyle 
        was not upgraded. Click for more: 'ms-help: // 
           MS.VSCC / commoner/redir/ redirect.htm?keyword 
              ="vbup2064"' 
      Picture1.FillStyle = 0 
'UPGRADE_ISSUE: PictureBox method Picture1.Circle was 
        not upgraded. Click for more: 'ms-help://MS.VSCC/ 
           commoner/redir/redirect.htm?keyword="vbup2064"' 
  Picture1.Circle (VB6.PixelsToTwipsX(Picture1.Width)/_ 
         2, VB6.PixelsToTwipsY(Picture1.Height) / 2),_ 
            VB6.PixelsToTwipsY(Picture1.Height) / 2 
End Sub 

In this code, the upgrade wizard has marked lines of code with an upgrade issue warning. The wizard also provides a link to MSDN documentation on more specifics of the upgrade issues.

Performance of the Upgrade Wizard

For small projects, the upgrade wizard works very quickly. For Visual Basic 6.0 projects that use COM and ActiveX components, the upgrade wizard updates a copy of the main Visual Basic 6.0 project. The original copy of the project is left unchanged. In addition, it creates a COM interoperability layer to enable the new Visual Basic .NET application to interact with the original COM components.

This means that when you upgrade Visual Basic 6.0 projects, all the referenced COM and ActiveX controls are not upgraded automatically. Instead, it uses the feature of interoperability mechanism provided by the Microsoft .NET Framework to interact with these COM and ActiveX components.

The pre-migration recommendations provided in this book have been suggested to improve the performance of upgrade wizard. The Visual Basic 6.0 code needs to can be changed as per pre-migration recommendations before upgrading it using the upgrade wizard.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020