Microsoft KB Archive/317157

From BetaArchive Wiki

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.

  1. In the Visual Studio .NET Tools program group, select Visual Studio .NET Command Prompt to open a command window.
  2. In the command window, use the cd command to move to the directory in which you want to generate the COM interop assemblies.
  3. Run the following command to generate the ADO 2.1 interop assembly:

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

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

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

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

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

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

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

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 "Create a COM Interop Assembly for the Access 10.0 Object Library" section, and then click Open.
  5. In the Add Reference dialog box, click OK.


STATUS

This behavior is by design.

MORE INFORMATION

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.


REFERENCES

For additional information about late binding, click the article numbers below to view the articles in the Microsoft Knowledge Base:

304661 HOWTO: Binding for Office Automation Servers with Visual Basic .NET


302902 HOWTO: Binding for Office Automation Servers with Visual C# .NET


For more information about Office Automation, see the following Microsoft Web site:

Office Development Support Center
http://support.microsoft.com/ofd


Keywords: kbnofix kbautomation kbprb KB317157