【问题标题】:Assert "id < 0" failed in Qt ActiveX在 Qt ActiveX 中断言“id < 0”失败
【发布时间】:2019-03-14 12:00:40
【问题描述】:

我使用 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 个),但 any 调用了 anyany 属性参考得到同样的错误:

调试错误!

程序:c:\Qt\5.11.1\msvc2015\bin\Qt5Cored.dll

模块:5.11.1
文件:qaxbase.cpp
线路:3763

断言:文件 qaxbase.cpp 中的“id

尝试通过 QMetaObject 访问属性时似乎失败了。

每次调用“References”对象时,我都会收到一条警告,然后是一个错误。该代码有效(我得到了正确数量的引用),但也许它是相关的:

CoCreateInstance 失败(Classe non enregistrée)
QAxBase::setControl:请求的控制 {eb106214-9c89-11cf-a2b3-00a0c90542ff} 无法实例化

此 CLSID 已正确注册并按预期引用“Microsoft.Office.Interop.Access.ReferencesClass”

谁能帮我做这个断言?

【问题讨论】:

  • 检查 Access 组件的注册位数与您的程序相同(32 位与 64 位注册表)
  • 已检查,CLSID 已在 32 位和 64 位注册表中注册。就像我说的,“app->References()->count()”和每个引用的“Item(...)”调用一样效果很好
  • 然而来自 CoCreateInstance 的错误告诉我们 CLSID eb106214-9c89-11cf-a2b3-00a0c90542ff 未注册。 .NET 事物中的“Microsoft.Office.Interop.Access.ReferencesClass”,而不是“纯”Access 事物,这正常吗?你为什么使用.NET?您可以使用 sysinternals 中的 procmon 之类的工具来检查您的应用使用了哪些注册表路径。
  • 我不知道 ActiveX / COM 内部。这是我在 RegEdit 中得到的(关键路径:HKEY_CLASSES_ROOT\CLSID\{EB106214-9C89-11CF-A2B3-00A0C90542FF}\InprocServer32\14.0.0.0):i.stack.imgur.com/sywNY.png
  • 如果您在 64 位操作系统上运行,这只是 64 位注册表(另外,您为什么要引用 .NET 互操作类?)

标签: c++ qt com activex


【解决方案1】:

我尝试了完全相同的代码,但直接使用 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 报告这个问题吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-16
    • 2018-06-02
    • 2011-04-02
    • 2014-12-18
    • 1970-01-01
    • 1970-01-01
    • 2019-07-11
    • 1970-01-01
    相关资源
    最近更新 更多