0

Here's the problem. I have a win32 (x86) program that has WinRT NuGet installed and working that needs to call a C# functions. I followed the instructions here and got everything working as a test C++/WinRT template app (see picture below). However, I followed these instructions to convert a C++ native console app and a C++ native desktop app. Neither of these projects can reference the WinRT Component project directly like the C++/WinRT template can. So I found the output .winmd file and referenced that instead and got both native projects to build. But now I get a different error: REGDB_E_CLASSNOTREG Class not registered == 0x8000000c : A concurrent or interleaved operation changed the state of the object, invalidating this operation.

What's the difference between a converted C++ app and a C++/WinRT template app?

Which part lets the C++/WinRT app reference the WinRT Component directly?

For third-party NuGet packages, is this a possible method to use? Or perhaps I should look into C++/CLI wrappers for this? (I have no experience with C++/CLI wrappers)

Edit

For clarification between the two projects I'm comparing, one is a Windows Console Application (C++/WinRT) which I think I got this option from the the WinRT VSIX extension. The other is the base C++ Console App (Run code in a Windows terminal. ...) that would download the C++/WinRT NuGet package after startup.

enter image description here

Thomas T
  • 59
  • 6
  • 1
    The "magic" happens inside the .vcxproj and .props files. Rather involved and with very little documentation. C++/CLI is completely unrelated to any of this. There is no CLR in the Windows Runtime. – IInspectable Sep 22 '21 at 19:35
  • `true` in the .vcxproj might be relevant. – IInspectable Sep 23 '21 at 08:23
  • @IInspectable Oddly enough, I can't find that tag in neither of my two C++ consuming projects nor the two C# authoring projects (I made another authoring project using [this](https://learn.microsoft.com/en-us/windows/uwp/csharp-winrt/create-windows-runtime-component-cswinrt#create-a-simple-windows-runtime-component-using-cwinrt)). Although on step 3 of the link, it mentions `true`. It sounds like the tag you mentioned is the C++ version, but I don't know for sure. – Thomas T Sep 23 '21 at 13:53
  • Does this answer your question? [Can you call from a C#/Winrt Component inside a base Win32 console template app (not WinForm/abstractions/wrappers or using the C++/Winrt template)?)](https://stackoverflow.com/questions/69321376/can-you-call-from-a-c-winrt-component-inside-a-base-win32-console-template-app) – Simon Mourier Sep 25 '21 at 10:10
  • @SimonMourier This question was more about the difference between the C++/WinRT Console template project vs a base Win32 Console app and adding the C++/WinRT NuGet package (see edit). But thanks for posting on that question! Your help is much appreciated. – Thomas T Sep 27 '21 at 17:18

0 Answers0