title: How can I obtain console application output when running it as a process in a C# DLL file?
body: <p>I am working on method in a DLL. In my method I have been writing to the event log to allow me to determine whether things are working as I expect. One of the tasks I do in the method is create a process and run a command line application and I want to be able to capture the output of this that is normally written to the console and write it to the eventlog.</p>
  <p>Code:</p>
  <pre><code>Process getNextIons = new Process();
  getNextIons.StartInfo.FileName = @&quot;&quot;&quot;C:\Program Files\OpenMS-1.6\PrecursorIonSelector.exe&quot;&quot;&quot;;
  getNextIons.StartInfo.Arguments = @&quot;-ini &quot;&quot;C:\Program Files\OpenMS-1.6\precursorionselector.ini&quot;&quot;&quot;;
  getNextIons.StartInfo.UseShellExecute = false;
  getNextIons.StartInfo.RedirectStandardOutput = true;
  getNextIons.Start();
  getNextIons.WaitForExit();
  System.Diagnostics.EventLog.WriteEntry(&quot;FMANWiff&quot;, &quot;IPS: &quot; + getNextIons.StandardOutput.ReadToEnd());
  </code></pre>
  <p>I have a console test application that calls my method and when I do this I am able to see that the process was started and ran correctly, however when I actually try to make use of the DLL, not using the test application, all I end up seeing is an entry:</p>
  <p>IPS: And none of the output. I can tell it is running, however, as I can see a number of output files being updated.</p>
  <p>Why am I not getting any output and how I can rectify this?</p>