PRB: Errors When You Reference the Access 10.0 Type Library with Visual Studio .NET (317157)
The information in this article applies to:
- Microsoft Access 2002
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- 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 LibraryNOTE: 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%"\Program Files\Common Files\System\ADO\msado21.tlb" /out:ADODB21.dll" - 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" - 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 - 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- In the Visual Studio integrated development environment (IDE), open the project in which you want to reference the Access 10.0 object library.
- On the Project menu, select Add Reference.
- In the Add Reference dialog box, click Browse.
- 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.
- In the Add Reference dialog box, click OK.
STATUS
This behavior is by design.
REFERENCESFor 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:
Modification Type: | Minor | Last Reviewed: | 8/23/2005 |
---|
Keywords: | kbAutomation kbnofix kbprb KB317157 kbAudDeveloper |
---|
|