Link to home
Start Free TrialLog in
Avatar of harry12
harry12

asked on

Communication between C++ / C# applications

I am launching an applicaton written in C# from within a C++ application and need to pass data to the C# application when it is launched and pass data back to the c++ application when the c# application is closed.  How can I accomplish this? I tried comman line arguments for the C++ to C# side and WM_COPYDATA for c# to c++ to no avail.  
ASKER CERTIFIED SOLUTION
Avatar of Mistralol
Mistralol

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Miguel Oz
What kind of applications are they? Console, Winforms, server/client.
can you modify them (C# app) to a server app?
Avatar of harry12
harry12

ASKER

They are basic UI apps where the user enters in data and the data entered is eventually saved to a file. The C++ app should send data from a file to the c# app where the data will get updated.  The c# app needs to send the updated data back to c++ app where it will be saved.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the files do not have a lot of read/writes uses it and it is not slow, then you can use the file as a means of communication. Just be aware that your programs must :
- Lock the file for multiple read and exclusive write. e.g.
  lock alternatives  
  FileShare
- File permissions
- File contents encoding (ASCII, UTF-8 or Unicode)
If your C# application is a console application, I would suggest to output your result of your C# app to the console and trap the output from your C++ application.
There are lots of examples of that in internet, for example:
http://stackoverflow.com/questions/300669/launch-app-capture-stdout-and-stderr-in-c
http://ubuntuforums.org/showthread.php?t=610271