Today's topic was dedicated to interopability between unmanaged C++ and managed C# sides. The speaker Denis P. proposed three concepts to reach the stated goal:
- C++/CLI language extensions as the most smooth approach. It enables a programmer to construct absolutely naturally-looking .NET classes with event sourcing, static members and properties in a convenient way.
- C# PInvoke - can be applied to simple tasks of invoking unmanaged static library methods. More complex classes require more coding (especially creating events, since PInvoke restricts unmanaged callbacks only to call delegates from managed code). Working with .NET types from unmanaged level is also obscured.
- COM Interop - smooth for programmers familiar with COM technology, allows to receive proper .NET classes with events but without static methods (COM architecture limitation). Creating .NET classes from COM level also possible but requires additional work.
Conclusion: for a simple interoperation it's better to use PInvoke, for some complex cases - C++/CLI language. COM is in the middle of these sides, but complex for the first try.
Enjoyed this article?
you might want to subscribe for our newsletter to get more content like this: