Mozilla XPCOM未注册 [英] Mozilla XPCOM is not registered
问题描述
我正在尝试为Firefox构建扩展程序.此扩展使用XPCOM组件(C ++ dll).我正在编译DLL,编译正常.
I'm trying to build an extension for Firefox. This extension uses an XPCOM component (a C++ dll). I'm compiling the DLL, compilation is OK.
下一步是在我的扩展程序中使用Javascript中的组件.我添加了代码以从我的c ++文件注册我的组件:
The next step would be to use the component in Javascript from my extension. I added the code to register my component from my c++ file :
static const mozilla::Module::CategoryEntry kSampleCategories[] = {
{ JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY, "greenfox", NS_SAMPLE_CONTRACTID },
};
在清单中,我声明XPCOM:
In my manifest, I declare the XPCOM :
component {03A6D0B4-22B9-11DF-B844-20D556D89593} components/GreenCodeLabFox.dll
问题是,当我尝试在JS中使用该组件时,似乎未注册该组件:
The problem is, when I try to use the component in JS, it seems it is not registered :
try {
greenfox;
return true;
} catch( e ) {
alert( e );
return false;
}
这给了我警报错误:
ReferenceError: greenfox is not defined
在错误控制台中,我没有任何消息.
In error console, I have no message.
如果没有错误消息,我该如何调试?顺便说一句,我的javascript.options.showInConsole设置为true.
How would I debug this if I have no error message ? By the way, my javascript.options.showInConsole is set to true.
谢谢!
推荐答案
每 https://developer.mozilla.org/zh-CN/XPCOM/XPCOM_changes_in_Gecko_2.0 必须使用binary-component
指令注册二进制组件.
Per https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0 you must use a binary-component
directive to register a binary component.
该页面还链接到示例;您只张贴了注册所需代码的一部分.
That page also links to an example; you only posted a part of the code required for registration.
如果该组件仍然无法正常工作,我将尝试通过错误控制台中的Components.classes [ contract id ]来获取它-这将显示问题是否出在组件注册上或仅包含全球财产部分.
If the component still doesn't work, I'd try to get it via Components.classes[contract id] from the Error Console - that will show if the problem is with the component registration or just with the global property part.
https://developer.mozilla.org/zh-CN/Troubleshooting_XPCOM_components_registration 对于故障排除可能很有用,尽管它有点过时了.
https://developer.mozilla.org/en/Troubleshooting_XPCOM_components_registration might be useful for troubleshooting, although it's a bit dated.
这篇关于Mozilla XPCOM未注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!