sound like a terrible idea? Yeah I thought so too. Needless to say im told I have to do it.
Situation:
Old MFC-based C++ gui application that reads and processes a whole lot of data sources into an internal datastructure, before displaying it to the user.
Problem:
I need that datastructure in .NET, in XML will do.
Solution:
- Make a function in the MFC app that writes the datastructure to a big XML string(easy).
- dllexport this function(or COM?)(as a C++ or C function or what?)
- Compile the MFC GUI app into a dll(how?).
- ???
- Reference the dll from .NET and P/Invoke method for great profit.
Is this insanity? Is it possible to compile a dll library from a GUI MFC app without changing it? Is it a horrible idea? What are my alternatives? Im pretty lost tbh.
I would be working on extracting the specific business logic code in the MFC app and sticking that stuff in a DLL, rather than trying to wrap up the whole app.
You might be making a false assumption here that it will take you less effort to wrap the MFC app up as a DLL (basically removing all the GUI code, adding a DLL main and modifying the build process to produce a DLL), than the effort to isolate the business logic code and put that in a new DLL project.
To wrap the GUI up as a DLL you will need a pretty good understanding of the dependencies of the business logic code and how it is used by the GUI, so you may as well just cut that stuff out.