nirsoft dll - MFC Dll with COM Interface

2 Answers

There is no simple way to make MFC Dll COM accessible. It is necessary to write a lot of COM code manually, making COM wrapper. If you don't have previous COM experience, this may be difficult. The second option from Jacob Seleznev's post looks less painful. C++/CLI wrapper which is internally linked to existing MFC dll, and exposes pure .NET interface to C# client, looks like optimal solution.

If MFC Dll exports C-style interface (API), and not classes, use PInvoke.

.net dll explorer

I am pretty new to managed/unmanaged interoperability and COM concepts.

I received a suggestion of using COM Interop, for using my existing MFC code in C#. But the problem for me is, i have a MFC Dll which is not a valid COM component. How can I make this MFC DLLs to have COM-accessible interfaces ready for use in .NET?

DLL Works in MFC App But No In .NET

The COM component probably needs single-threaded apartment (STA), while your .Net thread is in a multi-threaded apartment (MTA). Try to call your DLL only from a specific STA thread.