Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming the vsinstr.exe process writes that error to the standard error stream you can get the error message by capturing the process's standard error stream. To do this you'll need to set the ProcessStartInfo class's RedirectStandardError property to true, add an event handler to the Process class's ErrorDataReceived event and call the Process class's BeginErrorReadLine method <em>before</em> starting the vsinstr.exe process.</p> <p>Here's some sample code:</p> <pre><code>using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Threading; class CaptureProcessOutput { private ManualResetEvent m_processExited = new ManualResetEvent(false); private List&lt;string&gt; m_errorMessages = new List&lt;string&gt;(); private List&lt;string&gt; m_regularMessages = new List&lt;string&gt;(); private Process m_process = new Process(); public CaptureProcessOutput() { } public void Run (string[] args) { StringBuilder sb = new StringBuilder("/COVERAGE "); sb.Append("hello.exe"); m_process.StartInfo.FileName = "vsinstr.exe"; m_process.StartInfo.Arguments = sb.ToString(); m_process.StartInfo.UseShellExecute = false; m_process.Exited += this.ProcessExited; m_process.StartInfo.RedirectStandardError = true; m_process.StartInfo.RedirectStandardOutput = true; m_process.ErrorDataReceived += this.ErrorDataHandler; m_process.OutputDataReceived += this.OutputDataHandler; m_process.BeginErrorReadLine(); m_process.BeginOutputReadLine(); m_process.Start(); m_processExited.WaitOne(); } private void ErrorDataHandler(object sender, DataReceivedEventArgs args) { string message = args.Data; if (message.StartsWith("Error")) { // The vsinstr.exe process reported an error m_errorMessages.Add(message); } } private void OutputDataHandler(object sender, DataReceivedEventArgs args) { string message = args.Data; m_regularMessages.Add(message); } private void ProcessExited(object sender, EventArgs args) { // This is where you can add some code to be // executed before this program exits. m_processExited.Set(); } public static void Main (string[] args) { CaptureProcessOutput cpo = new CaptureProcessOutput(); cpo.Run(args); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload