The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
[UWP][C++] A SERIOUS BUG: WACK Failure: CoCreateInstance not supported RRS feed

  • Question

  • I add a AdDuplex Ad in my app, and then WACK Failure: API CoCreateInstance in api-ms-win-core-com-l1-1-0.dll is not supported for this application type.


    Friday, December 11, 2015 7:39 AM

All replies

  • I contact AdDuplex, they told me this is a Microsoft's bug. Please fix it.

    • Edited by [-] Friday, December 11, 2015 9:40 AM
    Friday, December 11, 2015 9:39 AM
  • Hello,

    "CoCreateInstance" API seems does not clarified as supported in UWP app Win32 and COM API for UWP apps What's your Windows SDK version? Does the above API used in your code?

    Best regards,

    Barry


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 16, 2015 10:11 AM
  • Hello,

    "CoCreateInstance" API seems does not clarified as supported in UWP app Win32 and COM API for UWP apps What's your Windows SDK version? Does the above API used in your code?

    Best regards,

    Barry


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    No one use CoCreateInstance, that's why it's called BUG, understand? And someone always changed my post title without my permission. MSFT, are you idle? If you have a lot of time, please fix bug first.

    Thursday, December 17, 2015 11:46 AM
  • CoCreateInstance and CoCreateInstanceEx are not valid APIs for Windows 8 Store or Windows Universal apps, and it's use will fail WACK.

    Instead you use CoCreateInstanceFromApp which is allowed by WACK. To simplify coding, there's an automatic conversion in the headers if you are building with the correct headers, toolset, and WINAPI_FAMILY partition:

    // combaseapi.h
    
    #if WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP
    
    __inline _Check_return_ HRESULT CoCreateInstance(
        _In_     REFCLSID rclsid, 
        _In_opt_ LPUNKNOWN pUnkOuter,
        _In_     DWORD dwClsContext, 
        _In_     REFIID riid, 
        _COM_Outptr_ _At_(*ppv, _Post_readable_size_(_Inexpressible_(varies))) LPVOID FAR* ppv)
    {
        MULTI_QI    OneQI;
        HRESULT     hr;
    
        OneQI.pItf = NULL;
    
    #ifdef __cplusplus
        OneQI.pIID = &riid;
    #else
        OneQI.pIID = riid;
    #endif
    
        hr = CoCreateInstanceFromApp( rclsid, pUnkOuter, dwClsContext, NULL, 1, &OneQI );
    
    #ifdef _PREFAST_
        if (SUCCEEDED(hr) && SUCCEEDED(OneQI.hr))
            _Analysis_assume_(OneQI.pItf != NULL);
        else
            _Analysis_assume_(OneQI.pItf = NULL);
    #endif
    
        *ppv = OneQI.pItf;
        return FAILED(hr) ? hr : OneQI.hr;
    }
    
    __inline _Check_return_ HRESULT CoCreateInstanceEx(
        _In_ REFCLSID                      Clsid,
        _In_opt_ IUnknown     *            punkOuter,
        _In_ DWORD                         dwClsCtx,
        _In_opt_ COSERVERINFO *            pServerInfo,
        _In_ DWORD                         dwCount,
        _Inout_updates_(dwCount) MULTI_QI *pResults )
    {
        return CoCreateInstanceFromApp(Clsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults);
    }
    
    #endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP
    #pragma endregion
    If the library you are using is actually calling CoCreateInstance, it will not pass WACK for the Windows Store. They need to rebuild the library to comply with the WINAPI_FAMILY for UWP.


    Monday, December 21, 2015 1:17 AM
  • No one use CoCreateInstance. This is a .NET Native's bug, .NET Native cannot work with C++/CX UWP.
    Monday, December 21, 2015 7:51 AM