Often the first time you create an XPCOM component, it may fail to register correctly.

There are several common reasons that registration can fail:

Did Registration Succeed?

It is important to not misdiagnose the problem. You can be certain that a component has failed to register by going to the Error Console and evaluating Components.classes["contract-id"].name where contract-id is your contract ID. If the response is your contract ID instead of an error, the component was successfully registered and this is the wrong page.

Load Failure of Binary Components

On the Mozilla trunk (Firefox 3, XULRunner 1.9), components that fail to load will print an error to the Error Console. Chrome errors must be enabled. If the error appears, you can use NSPR logging to see additional information about the failure by running Firefox from a command prompt:

rem Close all Firefox windows!
set NSPR_LOG_MODULES=nsNativeModuleLoader:5
set NSPR_LOG_FILE=C:\Path\to\logfile
"C:\Program Files\Mozilla Firefox\firefox.exe"

Examining this log for warning and errors may provide valuable clues why the component failed to load.

If using Firefox 4 / XULRunner 2.0, make sure that your extension is unpacked and you declared the binary component in your chrome.manifest. See XPCOM changes in Gecko 2.0

Parsing Errors in JavaScript Components

The most common reason for components written in JavaScript to fail is that there are parsing errors. These parsing errors should show up in the Error Console if chrome errors are enabled. To learn more about enabling chrome errors, see "How can I see errors in my code" in the Extension FAQs.

Registration Failure

If the module is loading correctly but doesn't register its components, try adding calls to Components.utils.reportError("Debug me!"); in NSGetModule() and other functions to try and find any errors.

General hints

Windows-specific hints

Linux-specific hints

Mac-specific hints

Further help

If the component still does not load, you may wish to ask for help. The extension-related places are often useful; please refer to the Community section on the Extensions page.