Microsoft KB Archive/814314

= BUG: Error at run time after you upgrade a Microsoft Visual Basic 6.0 project that uses the ImageList control to Microsoft Visual Basic .NET =

Article ID: 814314

Article Last Modified on 3/20/2006

-

APPLIES TO


 * Microsoft Visual Basic .NET 2002 Standard Edition

-



SYMPTOMS
When you upgrade a Microsoft Visual Basic 6.0 project that uses the ImageList control to a Microsoft Visual Basic .NET project by using the Microsoft Visual Basic .NET Upgrade Wizard, you receive the following exception when you run the project in Visual Basic .NET:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in axinterop.mscomctllib.dll



CAUSE
The Visual Basic .NET Upgrade Wizard wraps the ImageList control in the AxHost class. However, it does not modify the corresponding Visual Basic 6.0 code to access the underlying ImageList control. For example, the following code may be part of the migrated Visual Basic .NET code. ListView1.ColumnHeaderIcons = ImageList



WORKAROUND
To work around this problem, assign the underlying ImageList control instead of the wrapper control. You can access the underlying ImageList control by using the GetOcx method. To do this, locate the following code in the migrated Visual Basic .NET code: ListView1.ColumnHeaderIcons = ImageList Replace the existing code with the following code: ListView1.ColumnHeaderIcons = ImageList.GetOcx



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual Basic .NET (2003).



Steps to Reproduce the Behavior
 Create a new Visual Basic 6.0 Standard EXE project.

By default, Form1 is created. On the toolbox, click Components. Click the Controls tab, click to select the Microsoft Windows Common Controls 6.0 component, and then double-click on the selected item. Click OK. On the toolbox, double-click the ImageList control. On the toolbox, double-click the ListView control. Right-click the ImageList control, and then click Properties.</li> Click the Images tab, and then add pictures in the ImageList.</li>  Add the following code to the Form_Load function in the code editor: Private Sub Form_Load Dim mItem As ListItem Dim cItem As ColumnHeader ListView1.ColumnHeaderIcons = ImageList1 ListView1.ListItems.Clear ListView1.View = lvwReport Set mItem = ListView1.ListItems.Add(1,, &quot;hola&quot;) Set cItem = ListView1.ColumnHeaders.Add(,, &quot;Header&quot;) cItem.Icon = 2 End Sub </li> On the File menu, click Save. Close Visual Basic 6.0.</li> Open Visual Studio .NET IDE.</li> On the File menu, click Open, and then click Project.</li> Click to select the Visual Basic 6.0 project that you created.

Upgrade Wizard is started.</li> Follow the instructions to upgrade the project to Visual Basic .NET (2002).</li> On the Debug menu, click Start to run the application.

You receive the exception mentioned in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">