gpt4 book ai didi

ado - Msado60_Backcompat 在 CCommand::CreateParameter 中崩溃

转载 作者:行者123 更新时间:2023-12-04 15:19:41 25 4
gpt4 key购买 nike

我正在 Windows 7 64 位 SP1(已安装所有更新)上开发 ADO 应用程序(32 位):该应用程序必须在 Win XP 上运行。根据http://support.microsoft.com/kb/2517589/en-us我正在使用 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(函数内部的偏移量)处发生崩溃:

First-chance exception at 0x655ed5a6 (msado15.dll) in adosqlbugcheck.exe: 0xC0000005: Access violation writing location 0xcccccccc.
Unhandled exception at 0x655ed5a6 (msado15.dll) in adosqlbugcheck.exe: 0xC0000005: Access violation writing location 0xcccccccc.



Msado60_Backcompat.tlb:73728 字节,29.4.2011
msado15.dll:6.1.7601.17514,1019904 字节,21.11.2010

如果我使用 msado15.dll,则不会发生该错误。

有人可以重现错误吗?有解决办法吗?

最佳答案

问题解决了。我是从“C:\Program Files\Common Files”#import-ing 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 接口(interface)的理解,这不应该发生。但是自从 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 .

关于ado - Msado60_Backcompat 在 CCommand::CreateParameter 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7968280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com