我在该行的 try-catch 中放置了一个断点using
。另一个在result.wasSuccessful
排队。
当我这样做时,它会catch
说它返回一个错误。
但是,当该using
行没有断点时,不会捕获任何错误。
为什么会这样?
这是错误
+ $exception {"Cannot process request because the process (12400) has exited."} System.Exception {System.InvalidOperationException}
try
{
using (Process exeProcess = Process.Start(psi))
{
exeProcess.PriorityClass = ProcessPriorityClass.High;
var outString = new StringBuilder(100);
exeProcess.OutputDataReceived += (s, e) => outString.AppendLine(e.Data);
exeProcess.BeginOutputReadLine();
var errString = exeProcess.StandardError.ReadToEnd();
if (!string.IsNullOrEmpty(errString))
{
result.WasSuccessful = false;
result.ErrorMessage = errString;
}
}
}
catch (Exception ex)
{
result.WasSuccessful = false;
result.ErrorMessage = ex.ToString();
}