-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Labels
Description
I am spawning a command and forwarding streams to text readers. I thought I could additionally retrieve the standard output, even though it has been forwarder, from the command result. However doing so raises an ObjectDisposedException.
Medallion.Shell.Command shellCommand = Medallion.Shell.Command.Run(
executable: command.Program,
arguments: command.ArgumentValues,
options: opt =>
{
opt.Syntax(new NullSyntax());
});
shellCommand = shellCommand.RedirectStandardErrorTo(Console.Error);
shellCommand = shellCommand.RedirectTo(outputWriter);
shellCommand.Wait();
Medallion.Shell.CommandResult result = shellCommand.Result;
// ObjectDisposedException - cannot read from a closed text reader.
var r = result.StandardOutput;
The work around I found was to forward the standard output to another StringWriter and build the output from there.