Wxwidgets 如何在wxwebconnect中注册组件接口?

Wxwidgets 如何在wxwebconnect中注册组件接口?,wxwidgets,xpcom,xulrunner,Wxwidgets,Xpcom,Xulrunner,我正在用测试应用程序做一个实验,并在http://nerdlife.net/building-a-c-xpcom-component-in-windows/" 我根据需要调整MyComponent类,以便与testapp.exe(不是单独的dll)一起编译,在MyApp::OnInit上,我有以下几行代码: ns_smartptr<nsIComponentRegistrar> comp_reg; res = NS_GetComponentRegistrar(&comp_reg

我正在用测试应用程序做一个实验,并在http://nerdlife.net/building-a-c-xpcom-component-in-windows/"

我根据需要调整MyComponent类,以便与testapp.exe(不是单独的dll)一起编译,在MyApp::OnInit上,我有以下几行代码:

ns_smartptr<nsIComponentRegistrar> comp_reg;
res = NS_GetComponentRegistrar(&comp_reg.p);
if (NS_FAILED(res))
    return false;

ns_smartptr<nsIFactory> prompt_factory;
CreateMyComponentFactory(&prompt_factory.p);

nsCID prompt_cid = MYCOMPONENT_CID;
res = comp_reg->RegisterFactory(prompt_cid,
                                "MyComponent",
                                "@mozilla.org/mycomp;1",
                                prompt_factory);
并获取以下异常: 无法转换JavaScript参数arg 0[nsISupport.QueryInterface]

第一个警报显示“对象”,因此

Components.classes[cid].createInstance()
正在返回创建的实例

第二个警报显示“未定义”,因此XULRunner无法识别接口nsimComponent。 如何在wxWebConnect环境中动态注册nsIMyComponent接口


我不知道这里发生了什么。我要检查的第一件事是,您的组件是可编写脚本的(我假设是,因为您从中复制的演示是可编写脚本的)。接下来我要检查的是,您是否可以实例化其他标准XULRunner组件并获取它们的接口(尝试类似“alert('components.interfaces.nsIFile');”——至少在我的wxWebConnect版本中,这会显示一个带有字符串“nsIFile”的警报框

此外,我认为检查错误控制台以确保没有报告错误或警告是值得的


我不确定这里发生了什么。我要检查的第一件事是您的组件是否可以编写脚本(我认为是的,因为您从中复制的演示是)。接下来我要检查的是您是否可以实例化其他标准XULRunner组件并获取其接口(尝试类似“alert('components.interfaces.nsile')-至少在我的wxWebConnect版本中,这会显示一个带有字符串“nsIFile”的警报框

此外,我认为检查错误控制台以确保没有报告错误或警告是值得的

Components.classes[cid].createInstance()
window.open('chrome://global/content/console.xul', '', 'chrome,dialog=no,toolbar,resizable');