Difficulty consuming a C++ WinRT component in a Desktop App #1881
-
I have been following all of the canonical examples of projecting a simple C++ WinRT component into C#. I am able to consume the component via project reference. And I can consume in a Console App via NuGet. However, I have spent days trying to consume via NuGet in a "Desktop App." In this case, a C# WinUI3 packaged app. I can't get it working in UWP either. The issue I am running into is a Class Not Registered (0x80040154 (REGDB_E_CLASSNOTREG)) exception. I've been searching and searching GitHub & google to no avail. This exception is common, but none of the solutions I have found have been applicable, or just don't work. Any working example is based on project reference, not a NuGet package. Does anyone have any guidance on getting past this roadblock? Is it even possible? I'm experimenting with developing some XAML controls in a C++ library, and would like to be able to distribute via NuGet package. I can post a (working & non-working) sample if necessary. Many Thanks - Jerry |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
For unpackaged apps, in your app manifest, you need to add |
Beta Was this translation helpful? Give feedback.
-
Hi And thank you, @dongle-the-gadget but I'm building packaged apps. I've read that blog a number of times, and even tried additing the entries, to no effect. |
Beta Was this translation helpful? Give feedback.
-
What is the structure of your nuget package? In addition to the winmd dongle asked about, is the C++/WinRT component DLL also in the output folder where the app exe is running from? |
Beta Was this translation helpful? Give feedback.
I have a feeling the issue here might be the
win10-x64
in theruntimes
folder and that it should instead bewin-x64
due to the RID graph change in .NET. But let me try this out locally and get back to you. It is typically also recommended to package the winmd in the nuget package in another folder parallel tolib
like awinmd
folder, but typically the winmd is only needed when doing cross process calls which I believe isn't the case here.