locked
How to call COM in metro style app

    Question

  • I have one COM library, which is developed by VC++, and I used CoCreateInstanceFromApp to create COM object, but it always fail, and error code is 0x80040154 (the class is not registered), I know Metro Style App does not have access to registry, and I should add this COM into my app manifest, but how? I have tried some ways, but no effectIs.

    Is there anybody know it? thanks in advance.

    Thursday, May 10, 2012 9:20 AM

Answers

  • Yes: the COM library can make calls only to Win32 functions available to Metro style apps.

    --Rob

    • Proposed as answer by Jesse Jiang Friday, May 18, 2012 8:16 AM
    • Marked as answer by Jesse Jiang Friday, June 1, 2012 9:29 AM
    Friday, May 11, 2012 5:48 PM
    Owner
  • There is one manifest file you will use for RegFree COM in Metro style apps. It should be named Application.manifest, include this in your solution and set the Content = True and File type = Document.


    David Lamb

    • Proposed as answer by Mike Wednesday, May 30, 2012 2:45 AM
    • Marked as answer by Jesse Jiang Friday, June 1, 2012 9:29 AM
    Friday, May 18, 2012 11:25 PM
    Moderator

All replies

  • Metro style apps cannot instantiate arbitrary COM apps. From the documentation for CoCreateInstanceFromApp:

    Only built-in classes that are supported in the app container are supplied. Attempts to activate unsupported classes, including all classes installed by 3rd-party code as well as many Windows classes, result in error code REGDB_E_CLASSNOTREG.

    To use your COM library in a Metro style app the library will need to be available via registration free COM and deployed with the Metro style app in the Metro style app's app package.

    --Rob

    Thursday, May 10, 2012 5:40 PM
    Owner
  • As for COM library itself, do all functions invoked in this COM must be compliant to Metro Style app?

    I created xxx.exe.manifest and xxx.dll.manifest in the same directory as xxx.exe, but it seems that CoCreateInstanceFromApp still fail.

    Thanks.

    Friday, May 11, 2012 10:06 AM
  • Yes: the COM library can make calls only to Win32 functions available to Metro style apps.

    --Rob

    • Proposed as answer by Jesse Jiang Friday, May 18, 2012 8:16 AM
    • Marked as answer by Jesse Jiang Friday, June 1, 2012 9:29 AM
    Friday, May 11, 2012 5:48 PM
    Owner
  • There is one manifest file you will use for RegFree COM in Metro style apps. It should be named Application.manifest, include this in your solution and set the Content = True and File type = Document.


    David Lamb

    • Proposed as answer by Mike Wednesday, May 30, 2012 2:45 AM
    • Marked as answer by Jesse Jiang Friday, June 1, 2012 9:29 AM
    Friday, May 18, 2012 11:25 PM
    Moderator