Hasan Shouman Hasan Shouman - 9 months ago 70
C# Question

How to catch the returned object from another process in C#

I have a c# program that will call another c# program using Process.start() that I also have the source code.

How I can return a string for example from the second program that it can be read by the caller program.

Thanks

Answer Source

The simplest way would probably be to write it to the standard output (i.e. the console) of the "child" process. The "parent" process can then read the standard output (and error) of that process. See Process.StandardOutput.

Alternatively, you could use sockets, named pipes or something like that. That's certainly significantly harder, but would be appropriate if you wanted to make multiple requests/responses through the process.