Microsoft KB Archive/831486

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

Article ID: 831486

Article Last Modified on 4/23/2007

-

APPLIES TO


 * Microsoft Visual Basic .NET 2002 Standard Edition

-





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:  In Windows Explorer, navigate to the folder that contains the vbu.exe file. This file is typically located in the following folder:

\Microsoft Visual Studio .NET\Vb7\VBUpgrade

Note  is a placeholder for the installation path of Visual Studio .NET on your computer. 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:  Start a text editor (such as Notepad).  Type the following XML code in the text editor:     </li> On the File menu, click Save.</li> In the Save As dialog box, navigate to the folder that you located in step 1.</li> In the File name box, type vbu.exe.config .</li> Click Save.</li></ol> </li> Run the Visual Basic .NET Upgrade Wizard to upgrade your Visual Basic 6.0 project.

The behavior that is mentioned in the &quot;Symptoms&quot; section of this article does not occur.</li></ol>

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: <ol> 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.</li>  In the .resx file, locate all the occurrences of the following value for the Version attribute: 1.0.5000.0 </li>  Replace each occurrence of the code that you located in step 2 with the following Version attribute value: 1.0.3300.0 </li> Save the .resx file, and then exit the text editor.</li> 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 &quot;Symptoms&quot; section of this article does not occur.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_section">

Steps to Reproduce the Behavior

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

By default, the Form1 form is created.
 * 1) Add a CommandButton control to Form1.
 * 2) Add a TextBox control to Form1.
 * 3) 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.
 * 1) Save Form1, and then save the Standard EXE project.
 * 2) Exit Visual Basic 6.0.
 * 3) Start Visual Studio .NET 2002.
 * 4) On the File menu, point to Open, and then click Project.
 * 5) In the Open Project dialog box, locate the project file that you saved in step 6. Click the project file.
 * 6) Click Open to display page 1 of the Visual Basic .NET Upgrade Wizard.
 * 7) On the Visual Basic .NET Upgrade Wizard, click Next on page 1, click Next on page 2, and then click Next on page 3.
 * 8) When the Visual Basic .NET Upgrade Wizard prompts you to create a new folder, click Yes. Click Next on page 4.
 * 9) In Solution Explorer, double-click Form1.vb.

The behavior that is mentioned in the &quot;Symptoms&quot; section of this article occurs.

<div class="references_section">