C++ – NS_ERROR_XPC_GS_RETURNED_FAILURE error code

cfirefoxfirefox-addonxpcomxul

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!

Best Answer

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.

Related Topic