How to call COM inetrface in metro app?


  • I have a COM component, i want to use it in my metro app.

    this is my code:

    	ComPtr<IMyEngine> spFactory;
    	HRESULT hr = CoCreateInstance(CLSID_MyEngine, nullptr, CLSCTX_INPROC_SERVER, IID_IMyEngine, &spFactory);

    after return back from CoCreateInstance:

    hr REGDB_E_CLASSNOTREG 0x80040154 Class not registered HRESULT

    But in my win32 test app, it can work.

    Does somebody know why?


    Friday, March 16, 2012 3:01 AM


All replies

  • how to call COM interface in metro app? I am eager to know the answer. maybe CoCreateInstance is not available in metro?
    Friday, March 16, 2012 2:20 PM
  • Metro style apps cannot read the registry and so cannot load registered COM objects. You will need to include the object's DLL in your package and load it via registration free COM.

    See Creating Registration-free COM objects and Simplify App Deployment with ClickOnce and Registration-Free COM (this targets older platforms, but should give the general idea of what you need to do).


    Friday, March 16, 2012 7:27 PM
  • Thanks, i'll try it.


    Monday, March 19, 2012 9:55 AM
  • Hello Rob,

    I want to call COM object in metro app.

    I have read Reg-free documents.

    I use CoCreateInstanceFromApp() in my metro app.

    But, I don't know how to add my COM dll to my project.

    In addition, I don't know how to modify the manifest.

    any sample codes?


    Tuesday, May 8, 2012 8:28 AM