views:

565

answers:

2

I'm developing extension for Firefox which calls XPCOM component writen in C++ and I get this error:

[Exception... "Component returned failure code: 0x80570016
(NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]"  nsresult: "0x80570016
(NS_ERROR_XPC_GS_RETURNED_FAILURE)"  location: "JS frame :: 
chrome://testtest/content/mytest.js :: loadTestPage :: line 128"  data: no]

When I try to execute this code from java script:

cid = '@myCompany.com/MyComponent;1';
obj = Components.classes[cid].getService(Components.interfaces.IMyComponent);

Does anybody know what this error code means?

This error occures only on few machines running Vista (both x86 and x64) running FF 3.5.2 (32-bits official build, even after FF is reinstalled and new profiles are created), on other platforms it is working. XPCOM component is compiled with Visual C++ 2008 (sp1).

I tried to delete compreg.dat and xpti.dat and it doesn't work, I also tried to create new profile and then install extension again but still I get the same error.

I know for a fact that Firefox successfully loads my XPCOM component and that component is working, because I can access and use it from another component written in javascript.

Evaluating from error console also works.

Expression:

Components.classes['@myCompany.com/MyComponent;1'].getService(
    Components.interfaces.IMyComponent);

returns:

[xpconnect wrapped IMyComponent]

Thanks!

+1  A: 

The error means that your component threw during the getService call.

sdwilsh
C++ XPCOM componten is also called from another JS component and it works, but from extension it keeps failing. This happens only on few machines running Vista OS and FF 3.5.2 (even when FF is reinstalled and with new profile). Also I tried to evaluate: Components.classes['@myCompany.com/MyComponent;1'].getService(Components.interfaces.IMyComponent) expression from error console and it works (message in error console is [xpconnect wrapped IMyComponent])Thanks.
Mladen Jankovic
It could also happen for recursive service loads. It's possible that you are calling getService on your component recursively.
sdwilsh
+2  A: 

It's also possible that you're trying to call .getService while you're still in the middle of component registration. You should not try to create any external components during registration, because they may not be registered or completely available yet.

bsmedberg