views:

290

answers:

2

I have a pure C++ application developed using VC 6.0. I would like this application to make use of a library developed in C#. How do I call the methods in the C# library from my native executable? I do not want to convert my un-managed C++ native application to managed code. Similarly, how do I do the reverse? Is PInvoke the only option? I would appreciate any references or pointers for the same.

+2  A: 

To call into managed code from unmanaged C++, use ClrCreateManagedInstance, or export your types in your managed assembly as COM visible, and use COM. To call into unmanaged code from managed, use COM or P/Invoke.

1800 INFORMATION
+1  A: 

Microsoft's main line on this is use COM interop. There is however another option, sometimes referred to as "Reverse P/Invoke" there is a interesting blog post here and some more here

Also, if you have Delphi.NET (now defunct) this language allows you to export static methods like you would any dll function then you can call into the Delphi.NET assembly just like a normal native Dll.

Tim Jarvis