“Invalid procedure call or argument” error on “New ADODB.Connection” only if compiled on Windows 7

后端 未结 2 1960
离开以前
离开以前 2021-02-10 07:21

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 t

相关标签:
2条回答
  • 2021-02-10 07:57

    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.

    0 讨论(0)
  • 2021-02-10 08:13

    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.

    0 讨论(0)
提交回复
热议问题