I have an existing program win32 (x86) console app that needs to call managed code (C# from a .Net .dll
). The .dll
is not exposed to COM, but can be called from a C#/WinRT Component and referenced by C++/WinRT Console Template app, BUT I can't seem to call it from a win32 x86 console app even after installing the C++/WinRT NuGet package. I've built and ran this example but the consuming apps are always using the C++/WinRT template. When I try to reproduce the example with a base win32 app, I get the error REGDB_E_CLASSNOTREG Class not registered
.
I found another example showing how to consume a C++/WinRT component from a win32 app, without registering classes. I thought this was my answer. However the process involves going into the application manifest and specify activatable WinRT classes by referencing the outputted .dll
file whenever the C++/WinRT component builds.
Here's the problem: C#/WinRT components do not output a (see Edit) With the .dll
file, only the .winmd
..winmd
file, I can still reference the classes and build my project, But I end up with the same REGDB_E_CLASSNOTREG Class not registered
error. I assume both the C++/WinRT and C#/WinRT components would compile into something that is in an Intermediate Language (see comments), but why does C++/WinRT output a .dll
and a .winmd
, while C#/WinRT only outputs .winmd
files? I tried to use WinRT.Runtime.dll
in place of the outputted .dll
but that didnt work either.
I'm at a loss. I posted another question about the difference between the C++/WinRT template vs win32 with C++/WinRT NuGet package.
Main Problem: Can I use a C# .dll
(not COM exposed) in a base win32 console app somehow?
Edit
I realized that I was using a C# Windows Runtime Component template that was specific to UWP. This might be why there was no outputted .dll when built.
Following Simon's reply, I was able to create a C# WinRT component that can be called from a Win32 console app. This C# WinRT component DOES output a .dll as well as .winmd. I followed a bit closer to the article Simon posted about consuming with C++ and managed to get it to work with basic C# functions.