Microsoft KB Archive/316163

= Error messages when you attempt to build a Class Library project in Visual Basic .NET or in Visual Basic 2005 =

Article ID: 316163

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual Basic 2005 Express Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



This article was previously published under Q316163



SYMPTOMS
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=8.0.0.0, 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.



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



RESOLUTION
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:   \Microsoft .NET\Framework\V1.0.3705   \Microsoft .NET\Framework\V1.1.4322   \Microsoft .NET\Framework\V2.0.50727  </li> Type the following command, and then press the ENTER:

regasm microsoft.visualbasic.dll

NOTE: This command creates and registers the type library for Microsoft.VisualBasic.dll.

</li> Switch back to Visual Studio .NET or Visual Studio 2005, and then rebuild the project.</li></ol>

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce the Problem
<ol> Start Visual Studio .NET or Visual Studio 2005, and then create a new Visual Basic Class Library project.</li> On the Project menu, click Add New Item.</li> In the Add New Item dialog box, select COM Class, and then click Open.

Note In Visual Studio 2005, click Add instead of Open.</li>  Add a function that exposes a collection to the ComClass1 class, as follows: Function Test As Collection

End Function </li> Build the project.

You receive the error message described in the &quot;Symptoms&quot; section of this article.</li></ol>

Keywords: kbvs2005swept kbvs2005applies kberrmsg kbprb KB316163

-

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

© Microsoft Corporation. All rights reserved.