BUG: Controls are located at the upper-left corner of a form after you run the Visual Basic .NET 2002 Upgrade Wizard (831486)



The information in this article applies to:

  • Microsoft Visual Basic .NET (2002)

SYMPTOMS

On a computer that has Microsoft Visual Studio .NET 2002 installed, you may install Microsoft .NET Framework version 1.1 in addition to Microsoft .NET Framework version 1.0. After you run the Microsoft Visual Basic .NET Upgrade Wizard to upgrade a Microsoft Visual Basic 6.0 project, all the controls may be located at the upper-left corner of the form. Also, the Task List window may contain multiple instances of the following design-time error:
Object type cannot be converted to target type.
This behavior only occurs at design time. At run time, all the controls are in their original locations.

CAUSE

The Visual Basic .NET Upgrade Wizard creates an XML-based resource format (.resx) file for each of your Visual Basic 6.0 forms. This .resx file contains a reference to the latest version of the System.Windows.Forms.dll assembly. If you installed .NET Framework version 1.1 in addition to .NET Framework version 1.0 on your computer, the Visual Basic .NET Upgrade Wizard adds a reference to version 1.0.5000.0 of the System.Windows.Forms.dll assembly in the .resx file. However, Visual Studio .NET 2002 loads a reference to version 1.0.3300.0 of the System.Windows.Forms.dll assembly. Because of this difference in the assembly versions, the Windows Forms Designer ignores the code that sets the Location property for each control. Therefore, each control is located at the upper-left corner of the form.

WORKAROUND

To work around this bug, you may use either of the following methods. However, Microsoft recommends that you create a configuration file for the Visual Basic .NET Upgrade Wizard.

Create a configuration file for the Visual Basic .NET Upgrade Wizard

Create a configuration file for the Visual Basic .NET Upgrade Wizard. In the configuration file, specify the version of the common language runtime for the Visual Basic .NET Upgrade Wizard to use as v1.0.3705. If you do this, the Visual Basic .NET Upgrade Wizard adds a reference to version 1.0.3300.0 of the System.Windows.Forms.dll assembly in the .resx file for each of your forms. To use this method to work around the bug, follow these steps:
  1. In Windows Explorer, navigate to the folder that contains the vbu.exe file. This file is typically located in the following folder:

    %InstallationPath%\Microsoft Visual Studio .NET\Vb7\VBUpgrade

    Note %InstallationPath% is a placeholder for the installation path of Visual Studio .NET on your computer.
  2. In the folder that you located in the previous step, create a file that is named vbu.exe.config. To do this, follow these steps:
    1. Start a text editor (such as Notepad).
    2. Type the following XML code in the text editor:
      <configuration>
          <startup>
              <requiredRuntime version="v1.0.3705" safemode="true"/>
          </startup>
          <runtime>
              <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                  <publisherPolicy apply="no" />
              </assemblyBinding>
          </runtime>
      </configuration>
    3. On the File menu, click Save.
    4. In the Save As dialog box, navigate to the folder that you located in step 1.
    5. In the File name box, type vbu.exe.config.
    6. Click Save.
  3. Run the Visual Basic .NET Upgrade Wizard to upgrade your Visual Basic 6.0 project.

    The behavior that is mentioned in the "Symptoms" section of this article does not occur.

Edit the .resx file for your form

Edit the .resx file for your form so that all the occurrences of the Version attribute for the System.Windows.Forms.dll assembly match the version of the assembly that Visual Studio .NET 2002 loads. To do this, follow these steps:
  1. Use a text editor such as Notepad to open the .resx file that corresponds to your form.

    This file is located in the same folder as your upgraded form file.
  2. In the .resx file, locate all the occurrences of the following value for the Version attribute:
    1.0.5000.0
  3. Replace each occurrence of the code that you located in step 2 with the following Version attribute value:
    1.0.3300.0
  4. Save the .resx file, and then exit the text editor.
  5. If your upgraded project is open in Visual Studio .NET, close your solution, and then reopen the project.

    If your upgraded project is not open in Visual Studio .NET, open the project.

    The behavior that is mentioned in the "Symptoms" section of this article does not occur.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Visual Basic 6.0.
  2. Create a Standard EXE project.

    By default, the Form1 form is created.
  3. Add a CommandButton control to Form1.
  4. Add a TextBox control to Form1.
  5. Make sure that the CommandButton control and the TextBox control are visible.

    Make sure that neither of these controls is located at the upper-left corner of Form1.
  6. Save Form1, and then save the Standard EXE project.
  7. Exit Visual Basic 6.0.
  8. Start Visual Studio .NET 2002.
  9. On the File menu, point to Open, and then click Project.
  10. In the Open Project dialog box, locate the project file that you saved in step 6. Click the project file.
  11. Click Open to display page 1 of the Visual Basic .NET Upgrade Wizard.
  12. On the Visual Basic .NET Upgrade Wizard, click Next on page 1, click Next on page 2, and then click Next on page 3.
  13. When the Visual Basic .NET Upgrade Wizard prompts you to create a new folder, click Yes. Click Next on page 4.
  14. In Solution Explorer, double-click Form1.vb.

    The behavior that is mentioned in the "Symptoms" section of this article occurs.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web sites:

Modification Type:MajorLast Reviewed:3/20/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kbvs2002sp1sweep kbDesigner kbwizard kbUpgrade kbCtrl kbControl kbWindowsForms kbForms kberrmsg kbbug KB831486 kbAudDeveloper