如果我在 win7 上编译 VB6 应用程序,ADODB.Connection 会出现“类不支持自动化或不支持预期接口"的错误.

如果我在 win7 上编译 VB6 应用程序,ADODB.Connection 会出现“类不支持自动化或不支持预期接口

问题描述:

我在我的 Win7 x64 机器上编译了一些 VB6 代码,结果 .exe 无法在任何其他机器上正确运行.

I compiled some VB6 code on my Win7 x64 machine and the result .exe will not run correctly on any other machine.

VB6 代码只是一个带有一个按钮的新模板 .exe 文件,引用了Microsoft ActiveX Data Objects 2.6 Library"以及按钮按下事件中的以下代码:

VB6 code is just a new template .exe file with one button, a reference to "Microsoft ActiveX Data Objects 2.6 Library" and the following code in the button press event:

Dim db
Set db = New ADODB.Connection

它在我的机器上正常运行,但没有其他人(甚至其他 Win7 x64 机器)(更新:我发现它运行的其他两个用户,其中一个是 Jeff Atwood!,但大多数机器都有同样的问题)

It runs correctly on my machine, but no others (even other Win7 x64 machines) (Update: I found TWO other users where it runs and one of them is Jeff Atwood!, but most machines have the same problem)

我检查了两台机器上的引用屏幕,看看引用是否失败(虽然它不会编译,但它编译得很好).一切看起来都是合法的.在 64 位机器上,引用进入 SysWow64 而不是 system32.

I checked the references screen on both machines to see if a reference failed (it wouldn't compile then though and it compiles fine). Everything looks legit. On the 64 bit machines, the references go into SysWow64 instead of system32.

我什至已经在 Vista 64 位机器上成功编译了它并让它正确运行.它只是在 Windows 7 上编译,然后在发生错误的任何其他机器上运行.

I've even compiled this successfully on a Vista 64 bit machine and had it run correctly. It's only the compile on the Windows 7 and then running on any other machine where the error happens.

这是在我的盒子上运行 CompChecker 的结果:

Here are the results of running CompChecker on my box:

注册表信息:ADODB.Connection 具有 GUID HKEY_CLASSES_ROOTCLSID{00000514-0000-0010-8000-00AA006D2EA4}

Registry info: ADODB.Connection has GUID HKEY_CLASSES_ROOTCLSID{00000514-0000-0010-8000-00AA006D2EA4}

InprocServer32 是 %CommonProgramFiles%Systemadomsado15.dll

InprocServer32 is %CommonProgramFiles%Systemadomsado15.dll

这是一个 Windows 7 SP1 问题.有关解决方法,请参阅 http://support.microsoft.com/kb/2517589.

This is a Windows 7 SP1 issue. See http://support.microsoft.com/kb/2517589 for workarounds.

还有其他方法可以解决这个问题:

There are other ways around this:

  1. 改用 ADO 2.8(来自 Win 7 RTM磁盘)
  2. 使用后期绑定(可能是最简单)
  3. 有一百万种东西人们正在尝试这个很长时间和愤怒的线程:Windows 7 中 MDAC ADODB COM 组件的重大变化服务包 1

另外,这里列出的 x64 Win 7 不支持 msado15.dll:http://support.microsoft.com/kb/983246.这是一个大页面,只需搜索 msado15.dll.

Also, another thing, msado15.dll is not supported on x64 Win 7 as listed here: http://support.microsoft.com/kb/983246. It's a big page, just search on msado15.dll.