Using a .NET class from native C ++ using C ++ / CLI as "middleware",

I need to use a class / assembly done in C # .NET from a native C ++ application. I assume that I need to create a wrapper class in C ++ / CLI that will expose its own methods in the header files, but use the .NET class if necessary. It is not clear to me how to convert data types from .NET to standard C ++ types.

Does anyone have sample code to learn?

Just the text I found on this: http://msdn.microsoft.com/en-us/magazine/cc300632.aspx

But the text is very old (using Managed C ++, not C ++ / CLI), and much remains unclear.

+3
source share
1 answer

Yes, you need to create a wrapper with C ++ / CLI around your managed assembly.

To mix your own and managed types, you can check this article for sample codes.

Primitive types with int, float, byte are converted for you. But other String types must execute themselves. For example, if you have your own pointer to char *, then your C ++ / CLI class will need to convert it to String in order to pass it to the Managed C # assembly.

+5
source

All Articles