c++ - 在 Qt ActiveX 中断言“id < 0”失败
问题描述
我使用 Microsoft Access 2010 ActiveX (COM) 制作了一个程序来显示项目的引用(.adp 文件):
Access::Application* app = new Access::Application(nullptr);
app->SetVisible(true);
app->OpenAccessProject("E:\\solulog_dev\\SoluTools\\app\\test\\sources\\utilitaires\\liste_aide.adp", true);
int nb_ref = app->References()->Count();
qDebug().nospace() << nb_ref << " references";
for(int ref_num = 1; ref_num <= nb_ref; ref_num++)
{
Access::Reference* ref = app->References()->Item(ref_num);
qDebug().nospace() << "Reference #" << ref_num << " : " << ref->Name() << " (" << ref->Guid() << ") : " << ref->FullPath();
}
app->CloseCurrentDatabase();
app->Quit();
但是在执行时,我得到了正确数量的引用(在本例中为 5 个),但是对任何引用的任何属性的任何调用都会得到相同的错误:
调试错误!
程序:c:\Qt\5.11.1\msvc2015\bin\Qt5Cored.dll
模块:5.11.1
文件:qaxbase.cpp
行:3763断言:文件 qaxbase.cpp 中的“id < 0”,第 3763 行
尝试通过 QMetaObject 访问属性时似乎失败了。
每次调用“参考”对象时,我也会收到警告,然后是错误。该代码有效(我得到了正确数量的引用),但也许它是相关的:
CoCreateInstance 失败 (Classe non enregistrée)
QAxBase::setControl: 请求的控制 {eb106214-9c89-11cf-a2b3-00a0c90542ff} 无法实例化
此 CLSID 已正确注册并按预期引用“Microsoft.Office.Interop.Access.ReferencesClass”
任何人都可以帮助我这个断言?
解决方案
我尝试了完全相同的代码,但直接使用 QAxObject,而不是通过使用 dumpcpp 生成的 C++ 命名空间:
QAxObject* app = new QAxObject("Access.Application", nullptr);
app->setProperty("Visible", true);
app->dynamicCall("OpenAccessProject(QString, bool)", "E:\\solulog_dev\\SoluTools\\app\\test\\sources\\utilitaires\\liste_aide.adp");
QAxObject* references = app->querySubObject("References");
int nb_ref = references->property("Count").toInt();
qDebug().nospace() << nb_ref << " références";
for(int ref_num = 1; ref_num <= nb_ref; ref_num++)
{
QAxObject* reference = references->querySubObject("Item(QVariant)", ref_num);
qDebug().nospace() << "Reference #" << ref_num << " : " << reference->property("Name").toString() << " (" << reference->property("Guid").toString() << ") : " << reference->property("FullPath").toString();
}
app->dynamicCall("CloseCurrentDatabase()");
app->dynamicCall("Quit()");
delete app;
而这一次,一切都完美无缺。不是关于错误实例化的错误,我得到每个引用的值......所以我认为这是一个 dumpcpp 错误。我应该将此问题报告给 Qt 吗?
推荐阅读
- python - 如何在 Python 中处理二进制文件中的对象
- airflow - 气流调度程序在没有错误或警告的情况下停止
- cmake - cmake 我可以停止 variable_watch 变量的钩子吗
- node.js - Stripe - nosuch setupintent
- .net - .Net HttpClient.GetStreamAsync() 的行为与 .GetAsync() 不同
- python - Python如何高效处理复杂的嵌套字典
- c++ - 电子奥林匹克:利润。90% 给出,一次测试错误答案
- google-apps-script - 如何在 Google 驱动器中创建文件时触发 Google Apps 脚本?
- javascript - 通过javascript访问新标签中的HTML元素
- java - 从 Bouncy Castle Java 获取原始密钥