Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘microsoft visual basic 6’

BUG: You receive an “Unexpected exception occurred during upgrade engine operation” error message when you run the Visual Basic .NET or Visual Basic 2005 Upgrade Wizard

Symptoms
When you run the Microsoft Visual Basic .NET or Microsoft Visual Basic 2005 Upgrade Wizard to upgrade your Microsoft Visual Basic 6.0 projects, you may receive the following error message:

Unexpected exception occurred during upgrade engine operation: Object is static; operation not allowed.
Resolution
You can use double-byte character set (DBCS) characters to name your Visual Basic 6.0 files and to name your Visual Basic 6.0 projects. You can also use DBCS characters to name the folders that contain your Visual Basic 6.0 files and to name the folders that contain your Visual Basic 6.0 projects. You can then run the Visual Basic .NET or Visual Basic 2005 Upgrade Wizard to upgrade these projects.
You receive the error message that is mentioned in the “Symptoms” section of this article if you use DBCS characters with 0×5b or 0×5c trailing bytes to name your Visual Basic 6.0 files, to name your Visual Basic 6.0 projects, or to name your Visual Basic 6.0 folders. You receive the error message because the Visual Basic .NET or Visual Basic 2005 Upgrade Wizard incorrectly interprets the trailing bytes of these DBCS characters as the ‘[‘ (0×5b) single-byte character set (SBCS) character and the ‘\’ (0×5c) SBCS character. Therefore, the Visual Basic .NET or Visual Basic 2005 Upgrade Wizard expects files, projects, or folders with names that contain these SBCS characters. However, these files, projects, or folders only contain DBCS characters, so you receive the error message.

BUG: You receive a “System.InvalidCastException” error message when you upgrade a Visual Basic 6.0 application that holds a user control to Visual Basic .NET or Visual Basic 2005

Symptoms
You upgrade a Microsoft Visual Basic 6.0 application that holds a user control to Microsoft Visual Basic .NET or Visual Basic 2005. The user control that the Visual Basic 6.0 application holds calls a custom event. When you run the Visual Basic .NET or Visual Basic 2005 application, you may receive the following error message:

An unhandled exception of type ‘System.InvalidCastException’ occurred in Project1.exe.
Additional information: Specified cast is not valid.
Resolution
This bug occurs when the index parameter determines that the code that the Visual Basic Upgrade Wizard generates does not pass the correct instance of the control array.

BUG: You can add a member after a zero index in a Visual Basic .NET collection

Symptoms
In a Microsoft Visual Basic .NET collection, you can add a member after a zero index by using the Add method, but the collection is one-based. However, when you add a member after a zero index, the member is added at the first index.
Note In a Microsoft Visual Basic 6.0 collection, you receive a “Subscript out of range” error when you try to add a member after a zero index by using the Add method.
Resolution
This bug occurs because the collection is implemented as an array with Empty placeholder to adjust for 1 based array as the value for the zero index. This collection implementation allows you to add a member after the zero index.

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

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.
Resolution
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.

BUG: “Type System.IO.IOException” error message after you upgrade to Visual Basic .NET or Visual Basic 2005

Symptoms
After you upgrade your Microsoft Visual Basic 6 application to Visual Basic .NET or Visual Basic 2005, you may receive the following “exception” error message:

An unhandled exception of the type ‘System.IO.IOException’ occurred in microsoft.visualbasic.dll.
Resolution
This behavior occurs when all of the following conditions are true: The Visual Basic Upgrade Wizard upgrades Visual Basic 6 code that uses the Open statement to open a given file.
-and-You do not explicitly specify shared access to open this file.
-and-You attempt to open this file a second time without first closing it.NOTE: You may also receive this error message if you try to open a given file a second time (without closing the first file handle) by using the FileOpen function in Visual Basic .NET or in Visual Basic 2005 without specifying the Share argument.