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



The information in this article applies to:

  • Microsoft Visual Basic .NET (2002)

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

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.

MORE INFORMATION

Steps to Reproduce the Problem

  1. 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.
  2. Save and compile this project to C.dll.
  3. 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.
  4. Add a reference to C.dll.
  5. 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
    					
  6. Save and compile this project to B.dll.
  7. 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.
  8. Add references to B.dll and C.dll.
  9. 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
    					
  10. Save and compile this project to A.dll.
  11. Create a new Visual Basic .NET Windows application.
  12. 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.
  13. Remove B.dll or C.dll, close the project, and then reload it.
  14. Add A.dll as a reference.

    Note that it is loaded successfully.
  15. Remove A.dll, and then re-add it.

    You receive the same error message described in step 12.

Modification Type:MajorLast Reviewed:2/2/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kberrmsg kbprb KB316142