I have written all the code for an application in C++. It is standard C++ written using Visual Studio 2010.
I want to create a GUI using .NET. Is it possible?
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There a plenty of options, here’s a few off the top of my head:
Wrap the c++ code in a Windows DLL,
call the c++ code from .NET using
p/invoke.
Wrap the c++ code in a com object,
.NET can directly use com objects.
Wrap the c++ code inside some type of
managed c++ wrapper (c++/CLI), load and use
that new assembly in the .NET GUI.
Some more exotic ideas:
Use some type of inter-process
communication, like sockets. Your c++
code would have to run in another
process. I guess you could also make
the c++ code into a web service.
Run the c++ code on the command line,
launched by the .NET GUI. Pass
parameters via command line
parameters, capture and parse the
standard-out text from the c++
program back in the .NET app.
Edit:
I’d recommend the DLL and p/invoke. The COM object would have advantages over a plain-old dll for passing more complicated types and exposing an object model, but COM objects a pain to create and install/register (even w/ ATL, manifest files, etc). Using C++/CLI always seems more complicated than it’s worth for a lot of projects – but it’s worth learning a bit about it if the other options become too limiting.