Win7sp1用VS2010 编译ADO程序无法通过,提示:

msjro.tlh(195): error C2146: 语法错误: 缺少“;”(在标识符“ConflictTables”的前面)
msjro.tlh(195): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
msjro.tlh(223): error C2146: 语法错误: 缺少“;”(在标识符“GetConflictTables”的前面)
msjro.tli(111): error C2143: 语法错误 : 缺少“;”(在“IReplica::GetConflictTables”的前面)
msjro.tli(115): error C2064: 项不会计算为接受 2 个参数的函数

等等

解决方法如下:
1.找到regtlibv12.exe。
2.下载msado60_Backcompat_i386.tlb拷贝到“C:\Program Files\Common Files\System\ado”
3.执行 AdoRegWithI386.bat,内容如下

cd C:\Program Files\Common Files\System\ado

copy C:\Windows\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe regtlibv12.exe

regtlibv12.exe msado60_Backcompat_i386.tlb

del  regtlibv12.exe 

pause


4.重新编译 应用程序。

 

注意:

32位系统需要注册Msado60_Backcompat_i386.tlb

64位WIN7系统(INTEL平台)需要注册:Msado60_Backcompat_i386.tlbMsado60_Backcompat_x64.tlb这2个文件;

64位WIN7系统(AMD平台)需要注册:Msado60_Backcompat_i386.tlbMsado60_Backcompat_ia64.tlb这2个文件;

3、替换程序代码

如果是VC++

将:

#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","adoEOF")

import "C:\\Program Files\\Common Files\\System\\ado\\msjro.dll" no_namespace rename("ReplicaTypeEnum", "_ReplicaTypeEnum")

替换为:

#import "C:\\Program Files\\Common Files\\System\\ado\\msado60_Backcompat_i386.tlb" no_namespace rename ("EOF", "adoEOF")

import "C:\\Program Files\\Common Files\\System\\ado\\msjro.dll" no_namespace rename("ReplicaTypeEnum", "_ReplicaTypeEnum")

上述方法同样能解决ADO应用程序不能在运行级别较低的操作系统上运行


注意:本文归作者所有,未经作者允许,不得转载