Kirix Support Forums

How to dynamically register new component interface?

Please post all general questions, comments, bug reports, and any other wxWebConnect feedback here.

How to dynamically register new component interface?

Postby jmerari on Tue Nov 02, 2010 3:05 am

I'm doing an experiment on the provided testapp, incorporating the xpcom tutorial at ... n-windows/

I adapt MyComponent class as necessary to compile with testapp.exe (not as separate dll), and on MyApp::OnInit I have the following lines:

Code: Select all
    ns_smartptr<nsIComponentRegistrar> comp_reg;
    res = NS_GetComponentRegistrar(&comp_reg.p);
    if (NS_FAILED(res))
        return false;
    ns_smartptr<nsIFactory> prompt_factory;

    nsCID prompt_cid = MYCOMPONENT_CID;
    res = comp_reg->RegisterFactory(prompt_cid,

Those lines are copied from GeckoEngine::Init(), using the same mechanism to register PromptService, etc.
The code compiles well and testapp.exe is running as expected.

I put javascript test as below :
Code: Select all
   try {"UniversalXPConnect");
      const cid = ";1";
      obj = Components.classes[cid].createInstance();
                alert(typeof obj);
      // bind the instance we just created to our interface
      obj = obj.QueryInterface(Components.interfaces.nsIMyComponent);
   } catch (err) {

and get the following exception:
Could not convert JavaScript argument arg 0 [nsISupport.QueryInterface]

The first alert says "object", so the line
Code: Select all

is returning the created instance.

The second alert says "undefined", so the interface nsIMyComponent is not recognized by XULRunner.
How to dynamically registering nsIMyComponent interface ??

Registered User
Posts: 1
Joined: Tue Nov 02, 2010 2:39 am

Return to wxWebConnect Questions, Thoughts & Feedback