简体   繁体   中英

Rewrite MFC DLL with C#?

I have a plugin DLL that I've written in C++ MFC loaded by a 3rd party application presumably written in C++ with MFC. My DLL has a GUI interface and is based on CWinApp; I guess somehow the message pump of my plugin cooperates with the message pump of the main app (?) I believe my DLL is probably loaded via LoadLibrary and started via a call to an exported function in my DLL. My plugin calls functions and classes that the 3rd party application exposes via a static lib that my DLL links against.

This is fine but working with MFC/C++ is frustrating as compared to working in WinForms and C#. So I'm wondering if it would be possible to have my DLL not use MFC but instead use winforms and C#? Is there some way this could work? I'm imagining I guess the DLL written in C# that exports a function that is called from the 3rd party app and then this starting a winforms app? Also my DLL needs to link to a static C++ library in order to interop with the 3rd party application. Would that be possible to access from C#? Or if not directly possible maybe I can write some kind of wrapper?

The easiest way would be to wrap your C# dll with a C++ dll. Just create a shell in managed C++ that accepts whatever calls need to be handled from the main program. It can then call into the C# dll and let it handle all the work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM