我正在Windows 7 64位SP1上开发一个ADO应用程序(32位)(安装了所有更新):该应用程序必须在Win XP上运行。根据{{3}}我正在使用msado60_backcompat。直到最近才有效,但现在它崩溃了。
我的代码(片段):
_CommandPtr cmd(__uuidof(Command));
cmd->ActiveConnection = dbconn;
cmd->CommandText = _T("SELECT [si] FROM [TTable] WHERE [TTable].[ti1]=?");
cmd->Parameters->Append(cmd->CreateParameter(L"@ti1", adTinyInt, adParamInput, 1, 7));
CreateParameter在msado60_backcompat中实现:
inline _ParameterPtr Command15::CreateParameter ( _bstr_t Name, enum DataTypeEnum Type, enum ParameterDirectionEnum Direction, ADO_LONGPTR Size, const _variant_t & Value )
{
struct _Parameter * _result = 0;
HRESULT _hr = raw_CreateParameter(Name, Type, Direction, Size, Value, &_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _ParameterPtr(_result, false);
}
raw_CreateParameter()将msado15.dll调用到CCommand :: CreateParameter。偏移量0x34f(函数内部的偏移量)发生崩溃:
adosqlbugcheck.exe中0x655ed5a6(msado15.dll)的第一次机会异常:0xC0000005:访问冲突写入位置0xcccccccc。
adosqlbugcheck.exe中0x655ed5a6(msado15.dll)的未处理异常:0xC0000005:访问冲突写入位置0xcccccccc。
Msado60_Backcompat.tlb:73728字节,29.4.2011
msado15.dll:6.1.7601.17514,1019904字节,21.11.2010
如果我使用msado15.dll,则不会发生错误。
有人可以重现错误吗?有解决方案吗?
答案 0 :(得分:7)
问题解决了。我从#C:\ Program Files \ Common Files中导入了msado60_backcompat.tlb#。如果我从“C:\ Program Files(x86)\ Common Files”导入版本,它可以工作。编译器从两个完全相同的UUID和其他所有的tlb文件生成tlh文件,它们的不同之处仅在于包含
typedef __int64 ADO_LONGPTR;
typedef ADO_LONGPTR PositionEnum_Param;
而另一个包含
typedef long ADO_LONGPTR;
typedef enum PositionEnum PositionEnum_Param;
根据我对COM接口的理解,这不应该发生。但是既然MS承诺他们真的犯了一个错误,它似乎就是它的样子。
仅供参考,MS有一个新的解决方案:http://blogs.msdn.com/b/psssql/archive/2011/10/03/yes-we-made-a-mistake-and-are-finally-going-to-fix-it.aspx。