This article was previously published under Q316163
This article has been archived. It is offered "as is" and will no longer be updated.
When you attempt to build a Class Library project in Visual Basic .NET 2002, and the project exposes a Collection type through Component Object Model (COM) interop, the build may fail with the following error message:
COM Interop registration failed. Error loading type library/DLL.
In Visual Basic .NET 2003, you receive the following error message:
COM Interop registration failed. Could not find a type library for assembly 'Microsoft.VisualBasic'.
In Visual Basic 2005, you receive the following error messagess:
error MSB3211:The assembly 'Microsoft.VisualBasic, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not registered for COM Interop. Please register it with regasm.exe /tlb.
error MSB3212: Error: Error loading type library/DLL.
This behavior occurs because the Collection type is defined in the Microsoft.VisualBasic.dll assembly. If the type library for Microsoft.VisualBasic.dll is not registered, the class library cannot be registered correctly.
To resolve this issue, follow these steps:
Start the Visual Studio .NET Command Prompt or the Visual Studio 2005 Command Prompt.
Change the current folder to one of the following folders:
Windows Directory\Microsoft .NET\Framework\V1.0.3705
Windows Directory\Microsoft .NET\Framework\V1.1.4322
Windows Directory\Microsoft .NET\Framework\V2.0.50727
Type the following command, and then press the ENTER:
NOTE: This command creates and registers the type library for Microsoft.VisualBasic.dll.
Switch back to Visual Studio .NET or Visual Studio 2005, and then rebuild the project.
This behavior is by design.
Steps to Reproduce the Problem
Start Visual Studio .NET or Visual Studio 2005, and then create a new Visual Basic Class Library project.
On the Project menu, click Add New Item.
In the Add New Item dialog box, select COM Class, and then click Open.
Note In Visual Studio 2005, click Add instead of Open.
Add a function that exposes a collection to the ComClass1 class, as follows:
Function Test() As CollectionEnd Function
Build the project.
You receive the error message described in the "Symptoms" section of this article.