Basically I have a bunch of unmanaged VC++ static libraries. And the VC++ GUI application which uses those and it is based on MFC. The goal is to replace the GUI app with the one done in C# instead but using all the same static libraries. The question is if this even possible, and if yes, then what is the right way to accomplish that?
Suggestions, anybody? Thanks.
Rob is correct – you can do it in C++/CLI entirely, but we found it most useful to wrap some native classes in a managed WinForms User Control class. This managed class contained an instance of the native class, and not only marshalled data like strings in method calls, but also converted native callbacks (implemented with boost::signal) to .NET events. The whole solution for this signal-event translation is spelled out in this question. The .NET WinForms User Control also trapped native exceptions and re-threw them as managed exceptions, and also did some translation of non-.NET interface (methods returning iterators) to a more .NET-styled interface, which you can read about in this question. We were then able to use the .NET class directly in a WPF application. Note that if you wrap it as a .NET class it will have to go in a DLL to be used from C#.