[C++/WinRT] loading a Windows Runtime Component (reg free) written in C#

Attila 41 Reputation points

I wonder if it is possible to use C++/WinRT to load a Windows Runtime Component implemented in C# (resulting a .winmd) file. It looks like it should be possible, but at runtime I'm getting a Class Not Available exception.

I've spent a long time trying to make the reg free technique work, by following this post


and by trying to adopt the code found here


I have posted my compiling but failing solution on Github, with some procmon diagnostic, showing that the C++ application is looking in the right .winmd file, but apparently, the class is not found?


Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Fay Wang - MSFT 5,201 Reputation points


    ​Welcome to our Microsoft Q&A platform!

    Currently only native UWP app to managed UWP component activation is supported. This means if you want to manage c# component from C++/WinRT, you need to create a C++ UWP app(e.g. C++/WinRT UWP app) and set the min target version of the C# project to 15063 or earlier. In that case, you can call the c# component from C++/WinRT UWP app.

    But for native desktop (non-packaged) app(C++) activating c# runtime component, currently it is not supported.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AlexanderSklar 11 Reputation points

    @Attila :
    I actually have a solution for >15063:
    We've identified a fix and we're pursuing a public doc update.
    In the meantime here's how to consume a C# WinRT component from C++/WinRT


    1 person found this answer helpful.
    0 comments No comments