Microsoft KB Archive/318559

= INFO: Using the Primary Interop Assembly for ADO (ADODB) in Visual Studio .NET =

Article ID: 318559

Article Last Modified on 11/28/2007

-

APPLIES TO


 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition

-



This article was previously published under Q318559



Caution ADO and ADO MD have not been fully tested in a Microsoft .NET Framework environment. They may cause intermittent issues, especially in service-based applications or in multithreaded applications. The techniques that are discussed in this article should only be used as a temporary measure during migration to ADO.NET. You should only use these techniques after you have conducted complete testing to make sure that there are no compatibility issues. Any issues that are caused by using ADO or ADO MD in this manner are unsupported. For more information, see the following article in the Microsoft Knowledge Base:

840667 You receive unexpected errors when using ADO and ADO MD in a .NET Framework application



SUMMARY
Visual Studio .NET includes a primary interop assembly (PIA) that you can use with earlier versions of Microsoft ActiveX Data Objects (ADO) and the COM interoperability features of the Microsoft .NET Framework.

To use the PIA, you must add a reference to ADODB in a Visual Studio .NET project. To add a reference to ADODB in your Visual Studio .NET project, follow these steps:
 * 1) Open your Visual Studio .NET project.
 * 2) On the Project menu, click Add Reference.
 * 3) In the Add Reference dialog box, click the .NET tab.
 * 4) Click adodb from the Component Name list, click Select, and then click OK.

NOTE: If you click Microsoft ActiveX Data Objects 2.x Library on the COM tab, .NET silently uses the PIA rather than importing the type library again.



MORE INFORMATION
A .NET interop assembly is a collection of types (that is, type definitions, not implementations) that are already defined in the corresponding Component Object Model (COM) library. With these type definitions, managed applications can bind to the COM types at compile time and provide information to the common language runtime about how the types should be marshaled at run time.

The PIA contains the official description of the types as defined by the publisher of those types. The publisher of the original COM type always signs the official description of the types. Therefore, the PIA is the official .NET type library for interoperability with the corresponding COM component.

Microsoft strongly recommends that you use the ADO PIA because the ADO PIA helps to avoid certain problems with ADO and .NET COM interoperability (for example, problems with marshaling or garbage collection).

At deployment time, ADO.NET-based PIA (Adodb.dll) is automatically included in a setup package by the Visual Studio .NET Setup Wizard. However, the actual COM-Based ADO components (msado15.dll and its dependencies) are not automatically included by the Visual Studio .NET Setup Wizard.

