Microsoft KB Archive/316142

= Error message when you add a COM component to convert the type library to a .NET assembly =

Article ID: 316142

Article Last Modified on 2/2/2006

-

APPLIES TO


 * Microsoft Visual Basic .NET 2002 Standard Edition

-



This article was previously published under Q316142



SYMPTOMS
When you add a Component Object Model (COM) component to your project's references, you may receive an error message similar to the following:

A reference to ' ' could not be added. Converting the type library to a .NET assembly failed. Could not load type  from assembly Interop. , Version=1.0.0.0.



CAUSE
This behavior occurs if all of the following conditions are true:
 * The COM component references another component and implements its class.

-and-
 * The referenced component references a third component.

-and-
 * You add one of the two referenced components to the project's references or attempt to re-add the component without reloading the project.



RESOLUTION
To resolve this issue, delete the component and the two referenced components from the project's references, reload the project, and then add the COM component again.



Steps to Reproduce the Problem
 Create an ActiveX DLL project in Microsoft Visual Basic 6.0. Change the project name to C, and then change the class module name to clsC . Save and compile this project to C.dll. Create another ActiveX DLL project in Visual Basic 6.0. Change the project name to B, and then change the class module name to clsB . Add a reference to C.dll.  Add the following code to the class module: Public Property Get Test As C.clsC

End Property

Public Property Set Test(Value As C.clsC)

End Property  Save and compile this project to B.dll.</li> Create a third ActiveX DLL project in Visual Basic 6.0. Change the project name to A, and then change the class module name to clsA .</li> Add references to B.dll and C.dll.</li>  Add the following code to the class module: Implements B.clsB

Public Property Get Test As B.clsB

End Property

Public Property Set Test(Value As B.clsB)

End Property

Private Property Set clsB_Test(RHS As C.clsC)

End Property

Private Property Get clsB_Test As C.clsC

End Property </li> Save and compile this project to A.dll.</li> Create a new Visual Basic .NET Windows application.</li> Add B.dll or C.dll as the reference, and then add A.dll to the project.

You receive the following error message:

A reference to 'A' could not be added. Converting the type library to a .NET assembly failed. Could not load type A.clsAClass from assembly Interop.A, Version=1.0.0.0.

</li> Remove B.dll or C.dll, close the project, and then reload it.</li> Add A.dll as a reference.

Note that it is loaded successfully.</li> Remove A.dll, and then re-add it.

You receive the same error message described in step 12.</li></ol>

Keywords: kberrmsg kbprb kbvs2005swept kbvs2005doesnotapply KB316142

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.