Article ID: 318559 - Last Review: November 28, 2007 - Revision: 4.3

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

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   (http://support.microsoft.com/kb/840667/ ) You receive unexpected errors when using ADO and ADO MD in a .NET Framework application
Expand all | Collapse all

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.

REFERENCES

For additional information about how to use ADO in Visual Studio .NET applications, click the article number below to view the article in the Microsoft Knowledge Base:
308044  (http://support.microsoft.com/kb/308044/EN-US/ ) INFO: Roadmap for Using ADO in .NET
For more information about the role and the use of Primary Interop Assemblies, see the following Microsoft Web site:
Primary Interop Assemblies (PIAs)
http://msdn2.microsoft.com/en-us/library/aa302338.aspx (http://msdn2.microsoft.com/en-us/library/aa302338.aspx)
For more information about .NET interop, see the following Microsoft Web site:
Calling COM Components from .NET Clients
http://msdn.microsoft.com/en-us/library/ms973800.aspx (http://msdn.microsoft.com/en-us/library/ms973800.aspx)

APPLIES TO
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2003 Professional Edition
Keywords: 
kbcominterop kbinfo KB318559
 

Article Translations