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 (834059)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
SYMPTOMSYou 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. CAUSEThis 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.WORKAROUNDTo work around this bug, locate the following code in
the form that is named Form1 of the Command1_Click event in a Visual Basic .NET application: Call UserControl11_MyCustomEvent(UserControl11, New UserControl1.MyCustomEventEventArgs(5)) Replace this code with the following: Call UserControl11_MyCustomEvent(UserControl11(0), New UserControl1.MyCustomEventEventArgs(5)) STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are
listed at the beginning of this article.
REFERENCESFor more information, visit the following Microsoft
Web site: For additional information about how to upgrade the
Microsoft Visual Basic 6.0 project to Microsoft Visual Basic .NET, click the
following article number to view the article in the Microsoft Knowledge Base: 317885
HOW
TO: Use the Visual Basic Upgrade Wizard
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbBug kberrmsg kbEvent kbCodeGen kbExceptHandling KB834059 kbAudDeveloper |
---|
|