Bonjour,
Lorsque je tente de recuperer le standardoutput d'un process j'obtiens cette erreur :
Comment eviter cette erreur ?System.InvalidOperationException : StandardOut has not been redirected or the process hasn't started yet.
Voici mon code :
Processinvocation est une sous classe de Process :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 private String executeProcess() { Dictionary<string, string> environmentVariables = getArtixEnvironment(); ProcessInvocation process = this.ProcessInvocation; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; foreach (string variableName in environmentVariables.Keys) { process.EnvironmentVariables.Remove(variableName); process.EnvironmentVariables.Add(variableName, environmentVariables[variableName]); } // May through ProcessorLaunchException - propagate those up process.Start(); proces.StartInfo.RedirectStandardOutput = true; String outStreamOutput = process.StandardOutput.ReadToEnd(); return outStreamOutput; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 public class ProcessInvocation : Process {... }
Partager