For vsinstr -coverage hello.exe
, I can use the C# code as follows.
Process p = new Process();
StringBuilder sb = new StringBuilder("/COVERAGE ");
sb.Append("hello.exe");
p.StartInfo.FileName = "vsinstr.exe";
p.StartInfo.Arguments = sb.ToString();
p.Start();
p.WaitForExit();
When there's an error, I get the error message : Error VSP1018: VSInstr does not support processing binaries that are already instrumented.
.
How can I get this error message with C#?
SOLVED
I could get the error messages from the answers.
using System;
using System.Text;
using System.Diagnostics;
// You must add a reference to Microsoft.VisualStudio.Coverage.Monitor.dll
namespace LvFpga
{
class Cov2xml
{
static void Main(string[] args)
{
Process p = new Process();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
StringBuilder sb = new StringBuilder("/COVERAGE ");
sb.Append("helloclass.exe");
p.StartInfo.FileName = "vsinstr.exe";
p.StartInfo.Arguments = sb.ToString();
p.Start();
string stdoutx = p.StandardOutput.ReadToEnd();
string stderrx = p.StandardError.ReadToEnd();
p.WaitForExit();
Console.WriteLine("Exit code : {0}", p.ExitCode);
Console.WriteLine("Stdout : {0}", stdoutx);
Console.WriteLine("Stderr : {0}", stderrx);
}
}
}
question from:
https://stackoverflow.com/questions/5005874/how-to-get-the-error-message-with-c-sharp 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…