Results 1 to 3 of 3

Thread: StandardOut has not been redirected or the process hasn't started yet.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    96

    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

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: StandardOut has not been redirected or the process hasn't started yet.

    from msdn...

    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
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    96

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width