1

行の try-catch にブレークポイントを配置しましたusing。もう1つは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();
}
4

1 に答える 1