I have a problem redirecting standard output of an application. It seems like this is some kind of bug in .NET.
I'm running Live555ProxyServer but I don't get any output even when console which starts does have a written output. This code works with any other console application but not with this one.
void StartProcess()
{
var process = new Process();
process.StartInfo.FileName = @"live555ProxyServer.exe";
process.StartInfo.Arguments = "-R";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += process_OutputDataReceived;
process.Start();
process.BeginOutputReadLine();
}
void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Debug.WriteLine(e.Data);
}
The source code of that application can be found here
That is because all output goes to stderr
instead of stdout
, see source code
You should add a handler for Process.ErrorDataReceived
and call Process.BeginErrorReadLine
and things will start going smoothly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With