StandardOut has not been redirected or the process hasn't started yet.
I run a program based on a timer in VB.NET, and it executes just fine when I don't try to retrieve the output. For some reason, though, I constantly get an error on the Dim myOutput line... Can anyone spot my error? output is a string.
Error: StandardOut has not been redirected or the process hasn't started yet.
Code:
Dim fetch As New System.Diagnostics.ProcessStartInfo("C:/perlprog.pl")
fetch.WindowStyle = ProcessWindowStyle.Hidden
Dim executable As System.Diagnostics.Process
executable = System.Diagnostics.Process.Start(fetch)
Dim myOutput As System.IO.StreamReader = executable.StandardOutput
executable.WaitForExit(timer1.Interval)
If executable.HasExited Then
output = myOutput.ReadToEnd
End If
If Trim(output) = "" Then
output = "No errors (really)."
End If
lblerr.Text = output
Re: StandardOut has not been redirected or the process hasn't started yet.
from msdn...
Quote:
InvalidOperationException....
The StandardOutput stream has not been defined for redirection; ensure ProcessStartInfo..::.RedirectStandardOutput is set to true and ProcessStartInfo..::.UseShellExecute is set to false.
try adding these line of code before starting the process....
Code:
fetch.UseShellExecute = False
fetch.RedirectStandardOutput = True
hth
kevin
Re: StandardOut has not been redirected or the process hasn't started yet.
I did and it suddenly didn't like the executable = System... line
error: The specified executable is not a valid Win32 application.
I assume since its a perl program (which is native to unix, but is adapted to Win32) I'm guessing that's an issue for redirecting output. Or do I need to assign the output stream from within the perl program?