Desktop Bridge using Nuget Microsoft.Windows.CppWinRT not working RRS feed

  • Question

  • I am planning to use an own C++/WinRT component in an existing MFC application. I tried to establish the desktop bridge in order to reference this component in the MFC application. For 2 days I tried several approaches, e.g.




    None of them gives me the possibilty to reference a generated header file of the component. 

    Is there anyone who has solved this? Will MS fix this gap?

    Thanks and regards,


    Thursday, September 5, 2019 9:02 AM

All replies

  • Hi,

    Thank you for postinghere.

    >>Desktop Bridge using Nuget Microsoft.Windows.CppWinRT not working

    You should use the NuGet. Have you made sure that package references are enabled?Package references, using the PackageReference node, manage NuGet dependencies directly within project files. I suggest you should try to install the Microsoft.Windows.CppWinRT NuGet package into your project and install (or update to) the latest version of the VSIX extension.

    For more details you could refer to the link: https://docs.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt#earlier-versions-of-the-vsix-extension

    Best Regards,

    Jeanine Zhang

    Friday, September 6, 2019 8:52 AM
  • Hi Jeanine,

    thank you for your reply. Yes, I know this article. I installed the NuGet package and also VSIX. Didn't work anyway.



    • Edited by milonass Friday, September 6, 2019 12:03 PM
    Friday, September 6, 2019 9:13 AM
  • Hi,

    Sorry for delay in reply.

    >>I installed the NuGet package and also VSIX. Didn't work anyway.

    Did you manually install the Microsoft.Windows.CppWinRT NuGet package instead of installing it automatically?

    When you create a new C++/WinRT project with the latest version of the VSIX extension installed, the new C++/WinRT project automatically installs the Microsoft.Windows.CppWinRT NuGet package. The Microsoft.Windows.CppWinRT NuGet package provides C++/WinRT build support (MSBuild properties and targets), making your project portable between a development machine and a build agent (on which only the NuGet package, and not the VSIX extension, is installed).

    I suggest you should convert an existing project by manually installing the Microsoft.Windows.CppWinRT NuGet package. After installing (or updating to) the latest version of the VSIX extension, open the existing project in Visual Studio, click Project > Manage NuGet Packages... > Browse, type or paste Microsoft.Windows.CppWinRT in the search box, select the item in search results, and then click Install to install the package for that project. 

    You need to set up the system as described below, and you can create, build, or open a C++/WinRT project and deploy it in Visual Studio:
    1,Because C++/WinRT uses features from the C++17 standard, the NuGet package sets project property C/C++ > Language > C++ Language Standard > ISO C++17 Standard (/std:c++17) in Visual Studio.
    2,It also adds the /bigobj compiler option.
    3,It adds the /await compiler option in order to enable co_await.
    4,It instructs the XAML compiler to emit C++/WinRT codegen.
    5,You might also want to set Conformance mode: Yes (/permissive-), which further constrains your code to be standards-compliant.
    6,Another project property to be aware of is C/C++ > General > Treat Warnings As Errors. Set this to Yes(/WX) or No (/WX-) to taste. Sometimes, source files generated by the cppwinrt.exe tool generate warnings until you add your implementation to them.

    Could you please provide us some specific steps to reproduce the issue, we will provide you with better help.

    Best Regards,

    Jeanine Zhang

    Tuesday, September 10, 2019 5:18 AM
  • I finally suceeded in referencing the component (don't remember in detail what settings I did. A lot!), but now I don't know how to implement the component:

    In "implementation"? In "factory_implementation". Why are all that complicated classes and structures generated? What's the prupose? Cannot find any example. Cannot find any documentation.

    To be honest: This is a desaster. Newer concepts should make things easier and not even more complicated, and COM really was complicated enough. 


    Wednesday, September 11, 2019 10:48 AM
  • Hi,

    I am glad you have succeeded in referencing the component

    Regarding how to implement the component, it seems to be related to UWP, I will help you move thread to UWP forum for better support.

    Best Regards,

    Jeanine Zhang

    Thursday, September 12, 2019 1:59 AM
  • Hi,

    The "factory_implementation" means it enables classes to be activated by the Windows Runtime and the "implementation" namespace contains implementation types, you can implement method, etc in it. About more details, you can refer to this document

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, September 12, 2019 6:09 AM