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



The information in this article applies to:

  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition

This article was previously published under Q318559

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 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: For more information about .NET interop, see the following Microsoft Web site:

Modification Type:MajorLast Reviewed:4/5/2004
Keywords:kbCOMInterop kbinfo KB318559 kbAudDeveloper