Microsoft KB Archive/317157

= PRB: Errors When You Reference the Access 10.0 Type Library with Visual Studio .NET =

Article ID: 317157

Article Last Modified on 8/23/2005

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition

-



This article was previously published under Q317157



SYMPTOMS
When you add a reference to the Access 10.0 object library to create a COM interop assembly, you may receive the following error message:

A reference to 'Microsoft Access 10.0 Object Library' could not be added. Converting the type library to a .NET assembly failed. A dependent type library 'OWC10' could not be converted to a .NET assembly. A dependent type library 'ADODB' could not be converted to a .NET assembly. Item has already been added.

When you use the Type Library Importer tool, Tlbimp.exe, to create a COM interop assembly for the Access 10.0 object library, you may receive the following error message:

TlbImp error: System.ApplicationException - The assembly for referenced type library, 'ADODB', will not be imported since it would overwrite existing assembly 'ADODB'.



CAUSE
When you set a reference to a COM object library, you must create and reference a COM interop assembly for each of the dependent object libraries. The Access 10.0 object library is dependent on Microsoft ActiveX Data Objects (ADO) 2.5 and the Microsoft Office XP Web Components. The Office XP Web Components are dependent on ADO 2.1. A conflict occurs when Visual Studio .NET attempts to create the COM interop assembly for ADO 2.1 by using the Adodb.dll file name. Because an assembly with this name has already been created for ADO 2.5, Visual Studio does not overwrite the file and reports the error.



RESOLUTION
To resolve this problem, manually create a COM interop assembly for the Access 10.0 object library, and then set a reference to the assembly.

Create a COM Interop Assembly for the Access 10.0 Object Library
NOTE: The file paths that are used in the sample commands are for default installations. The file paths on your computer may be different.  In the Visual Studio .NET Tools program group, select Visual Studio .NET Command Prompt to open a command window. In the command window, use the cd command to move to the directory in which you want to generate the COM interop assemblies. Run the following command to generate the ADO 2.1 interop assembly:

tlbimp %SYSTEMDRIVE%&quot;\Program Files\Common Files\System\ADO\msado21.tlb&quot; /out:ADODB21.dll&quot;

 Run the following command to generate the ADO 2.5 interop assembly:

tlbimp %SYSTEMDRIVE%&quot;\Program Files\Common Files\System\ADO\msado25.tlb&quot; /out:ADODB25.dll&quot;

 Run the following command to generate the Office XP Web Components interop assembly:

tlbimp %SYSTEMDRIVE%&quot;\Program Files\Common Files\Microsoft Shared\Web Components\10\owc10.dll&quot; /reference:ADODB21.dll

 Run the following command to generate the Access 10.0 interop assembly:

tlbimp %SYSTEMDRIVE%&quot;\Program Files\Microsoft Office\Office10\msacc.olb&quot; /reference:ADODB25.dll

</li></ol>

The following assembly files are generated:
 * Access.dll
 * Adodb21.dll
 * Adodb25.dll
 * Dao.dll
 * Mscomctllib.dll
 * Office10.dll
 * Owc10.dll
 * Vbide.dll

Reference the COM Interop Assembly

 * 1) In the Visual Studio integrated development environment (IDE), open the project in which you want to reference the Access 10.0 object library.
 * 2) On the Project menu, select Add Reference.
 * 3) In the Add Reference dialog box, click Browse.
 * 4) In the Select Component dialog box, browse to the directory in which you created the COM interop assemblies, select of all the assembly files that are listed in the &quot;Create a COM Interop Assembly for the Access 10.0 Object Library&quot; section, and then click Open.
 * 5) In the Add Reference dialog box, click OK.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce the Behavior

 * 1) In Visual Studio .NET, create a new Visual Basic or Visual C# Windows Application project.
 * 2) On the Project menu, select Add Reference.
 * 3) In the Add Reference dialog box, click the COM tab.
 * 4) In the list of components, select Microsoft Access 10.0 Object Library, click Select, and then click OK.

<div class="references_section">