“无效的过程调用或参数” “New ADODB.Connection”错误仅当在 Windows 7 上编译时

发布于 2024-12-28 06:51:40 字数 491 浏览 0 评论 0 原文

自从我在 Windows 7 中获得了一台新的开发机器(我的旧机器在 Windows XP 上)后,当我在 VB6 上编译一些遗留应用程序时,我遇到了一些问题

。如果我在我的 XP 机器上编译该项目,一切都很好。 如果我在 Windows 7 计算机上编译相同的项目,它仍然运行良好,但如果我尝试在 XP 计算机上运行它,则会出现此错误。

错误编号:5
说明:无效的过程调用或参数

感谢我的错误处理程序,我知道引发此错误的行是:

    Dim objConn As ADODB.Connection
--> Set objConn = New ADODB.Connection

我比较了两台机器上的引用,并且项目 - 引用是相同的:(Microsoft ActiveX 数据对象 2.7 库

什么可能导致此错误?

I'm experiencing some problem when I compile some legacy apps on VB6 since I got a new development machine in windows 7. (my old one was on Windows XP.)

If I compile the project on my XP machine, everything is fine.
If I compile the same project on my Windows 7 machine, it still run fine one it, but if I try to run it on a XP machine, I got this error.

Error Number : 5
Description : Invalid procedure call or argument

Thanks to my error handler, I know that the line that throw this error is :

    Dim objConn As ADODB.Connection
--> Set objConn = New ADODB.Connection

I compared the references on both machines and the Project - References are the same : (Microsoft ActiveX Data Objects 2.7 Library)

What could cause this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

穿透光 2025-01-04 06:51:40

这是已知的 Win7 SP1 中的问题 将在 SP2 中修复。

在 SP1 中处理该问题的方法是从 Win7 RTM 中复制旧的 ADO typelib 文件到 C:\Program Files (x86)\Common Files\System\ado 并在那里注册。

正如许多论坛主题所表明的那样,注册这个旧的 ADO 类型库并不是一项简单的任务。这是我们在商店中用于修复 ADO typelib 问题的批处理文件:

@echo off
set regtlib="%windir%\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe"
set subinacl="%~dp0subinacl.exe"
set target_dir=%CommonProgramFiles%\System\ado
if not "%CommonProgramFiles(x86)%"=="" set target_dir=%CommonProgramFiles(x86)%\System\ado

copy "%~dp0msado28_old.tlb" "%target_dir%\msado28_old.tlb" > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /setowner=Administrators > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /grant=Administrators=F > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /setowner=Administrators > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /grant=Administrators=F > nul
%regtlib% -u "%target_dir%\msado28.tlb"
%regtlib% "%target_dir%\msado28_old.tlb"

您需要 msado28_old .tlbsubinacl.exe 放置在与 install.bat 文件和 regtlibv12 的 .NET Framework 4.0 安装程序相同的文件夹中.exe 实用程序。

现在,您可以在 Win7 机器上重新编译引用 ADO 的项目,而不会在以前版本的 Windows 上出现兼容性问题。

This is a known problem in SP1 for Win7 which will be fixed in SP2.

The way to handle the issue in SP1 is to copy the old ADO typelib file from Win7 RTM in C:\Program Files (x86)\Common Files\System\ado and register it there.

Registering this old ADO typelib is not a trivial task as numerous forum threads have shown. Here is a batch file we use in our shop to fix ADO typelib issue:

@echo off
set regtlib="%windir%\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe"
set subinacl="%~dp0subinacl.exe"
set target_dir=%CommonProgramFiles%\System\ado
if not "%CommonProgramFiles(x86)%"=="" set target_dir=%CommonProgramFiles(x86)%\System\ado

copy "%~dp0msado28_old.tlb" "%target_dir%\msado28_old.tlb" > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /setowner=Administrators > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /grant=Administrators=F > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /setowner=Administrators > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /grant=Administrators=F > nul
%regtlib% -u "%target_dir%\msado28.tlb"
%regtlib% "%target_dir%\msado28_old.tlb"

You need both msado28_old.tlb and subinacl.exe placed in the same folder as the install.bat file and .NET Framework 4.0 setup for the regtlibv12.exe utility.

Now you can recompile your projects referencing ADO on the Win7 box with no compatibility issues on previous versions of Windows.

烟火散人牵绊 2025-01-04 06:51:40

这是一个已知的 Microsoft 问题,但我不认为这是一个错误;我认为出于安全原因兼容性被破坏。如果您有某些修补程序,则该问题可能存在于非 SP1 版本上已安装。 Microsoft 知识库中引用了几个选项。这是另一个文章提供更新。

我们遇到了这个问题,因此决定在所有开发人员计算机上部署向后兼容性补丁,并将所有旧版 ADO 引用替换为向后兼容性引用。这对我们来说效果很好。

This is a known Microsoft issue, but I don't think it was a bug; I believe compatibility was broken for security reasons. The problem could have existed on a non-SP1 builds if you had a certain hotfix installed. There are a couple of options referenced in the Microsoft KB. Here is another article providing an update.

We ran into this problem and we decided to deploy the Backwards Compatibility patch on all developer machines and replace all legacy ADO references with the Backwards Compatibility reference. This has worked well for us.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文