You receive an "Image Cannot be Converted to Icon" compiler error message after you upgrade a Visual Basic 6.0 project to Visual Basic .NET or Visual Basic 2005 (311337)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
This article was previously published under Q311337 SYMPTOMS After you complete the steps in the Upgrade Wizard to
upgrade a Visual Basic 6.0 project, when you try to run the newly created
Visual Basic .NET or Visual Basic 2005 project, you receive the following compiler error message:
Value of type 'System.Drawing.Image' cannot be converted
to 'System.Drawing.Icon'. The Upgrade Wizard does not report any
errors or warnings. NOTE: The Visual Basic .NET Upgrade Wizard is included in Visual
Studio .NET Professional. CAUSE This problem occurs because Visual Basic 6.0 code sets the Icon property of the form. In Visual Basic 6.0, the Icon property of a form is of type Image. In Visual Basic .NET or Visual Basic 2005, the Icon property is of type StdPicture. The following line causes this error message in the
Visual Basic .NET or Visual Basic 2005 project:
Me.Icon = Image1.Image
The following Visual Basic 6.0 code produces the above line:
Set Me.Icon = Image1.Picture
RESOLUTION To resolve this problem, replace the following code in the
upgraded Visual Basic .NET or Visual Basic 2005 project
Me.Icon = Image1.Image
with:
Dim bmp As Bitmap
bmp = Image1.Image
Me.Icon = Icon.FromHandle(bmp.GetHicon)
STATUSThis
behavior is by design.
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbmigrate kbprb KB311337 kbAudDeveloper |
---|
|