September 8th, 2011, 01:55 AM
Capture console output from process created in DLL
I am working on method in a DLL that gets called by another application. In my method I have been writing to the event log to aid debugging and generally to allow me to determine whether things are working. However, in this method I create a process and run another application and I want to be able to capture the output of the application and write it to the eventlog.
I have a console test application that calls my method and when I do this I am able to see the relevant entries in my event log. However when I actually try to make use of the DLL, not using the test application, all I end up seeing is an entry:
Process getNextIons = new Process();
getNextIons.StartInfo.FileName = @"""C:\Program Files\OpenMS-1.6\PrecursorIonSelector.exe""";
getNextIons.StartInfo.Arguments = @"-ini ""C:\Program Files\OpenMS-1.6\precursorionselector.ini""";
getNextIons.StartInfo.UseShellExecute = false;
getNextIons.StartInfo.RedirectStandardOutput = true;
System.Diagnostics.EventLog.WriteEntry("FMANWiff", "IPS: " + getNextIons.StandardOutput.ReadToEnd());
and none of the output. I can tell it is running however as I can see a number of output files being updated.
Does anyone know why I am not getting any output and how I can rectify this?
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!