Process.ErrorDataReceived Event


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Occurs when an application writes to its redirected StandardError stream.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

member ErrorDataReceived : IEvent<DataReceivedEventHandler,

The ErrorDataReceived event indicates that the associated process has written to its redirected StandardError stream.

The event only occurs during asynchronous read operations on StandardError. To start asynchronous read operations, you must redirect the StandardError stream of a Process, add your event handler to the ErrorDataReceived event, and call BeginErrorReadLine. Thereafter, the ErrorDataReceived event signals each time the process writes a line to the redirected StandardError stream, until the process exits or calls CancelErrorRead.


The application that is processing the asynchronous output should call the WaitForExit method to ensure that the output buffer has been flushed.

The following example uses the net view command to list the available network resources on a remote computer. The user supplies the target computer name as a command-line argument. The user can also supply a file name for error output. The example collects the output of the net command, waits for the process to finish, and then writes the output results to the console. If the user supplies the optional error file, the example writes errors to the file.

No code example is currently available or this language may not be supported.


for full trust for the immediate caller. This member cannot be used by partially trusted code.

.NET Framework
Available since 2.0
Return to top