Marshal a C++ class to C#
- by Adam Haile
I need to access code in a native C++ DLL in some C# code but am having issues figuring out the marshaling. I've done this before with code that was straight C, but seem to have found that it's not directly possible with C++ classes. Made even more complicated by the fact that many of the classes contain virtual or inline functions. I even tried passing the headers through the PInvoke Interop Assistant, but it would choke on just about everything and not really no what to do... I'm guessing because it's not really supported.
So how, if at all possible, can you use a native C++ class DLL from .NET code.
If I have to use some intermediary (CLR C++?) that's fine.