Microsoft KB Archive/815117

= You receive an exception when running .NET application on a computer that does not have Microsoft Data Access Components (MDAC) installed =

Article ID: 815117

Article Last Modified on 11/28/2007

-

APPLIES TO


 * Microsoft ADO.NET 1.0
 * Microsoft ADO.NET 1.1
 * Microsoft ADO.NET 2.0
 * Microsoft ActiveX Data Objects 2.7
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition

-





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



SYMPTOMS
You deploy a Microsoft .NET Framework application that accesses a database on a computer. The computer only has the .NET Framework Redistributable package installed. When you run the application, you may receive the following error message:

An unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will be shut down immediately.

QueryInterface for interface ADODB._Command failed.



CAUSE
The problem occurs because Microsoft Data Access Components (MDAC) is not installed on the computer. The .NET application uses MDAC to access the data from the database.



RESOLUTION
To resolve this problem, install MDAC on the computer. You can download MDAC from the following Microsoft Developer Network (MSDN) Web site:

Data Access downloads

http://msdn2.microsoft.com/en-us/data/aa937695.aspx



STATUS
This behavior is by design.



Steps to reproduce the problem
 Create a new Visual Basic .NET or Visual C# .NET Console Application project. On the Project menu, click Add Reference. On the .NET tab, double-click adodb in the Components Name list.  Replace the existing code with the following code:

Visual Basic .NET code
Module Module1

Sub Main Dim cnPubs As ADODB.Connection = New ADODB.ConnectionClass Dim rstblAuthors As ADODB.Recordset = New ADODB.RecordsetClass End Sub End Module

Visual C# .NET code
using System;

namespace MyTestApplication {   class Class1 {     [STAThread] static void Main(string[] args) {        ADODB.Connection cnPubs = new ADODB.ConnectionClass; ADODB.Recordset rstblAuthors = new ADODB.RecordsetClass; }   } }  On the Build menu, click Build Solution.</li> On a test computer, install only the .NET Framework Redistributable package (dotnetfx.exe). Verify that MDAC is not installed on the test computer.</li> Copy the Windows Application project that you created to the test computer.</li> Run the application. You receive the error message that is described in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">