microsoft / testfx

MSTest framework and adapter
MIT License
697 stars 250 forks source link

Handle InvalidOperationException when accessing process ID #3250

Closed Evangelink closed 1 month ago

Evangelink commented 1 month ago

Got some exception in our testing suite:

Unhandled Exception: System.InvalidOperationException: No process is associated with this object.
   at System.Diagnostics.Process.EnsureState(State state)
   at System.Diagnostics.Process.EnsureState(State state)
   at System.Diagnostics.Process.get_Id()
   at Microsoft.Testing.Platform.Hosts.TestHostControllersTestHost.<InternalRunAsync>b__21_0(Object sender, EventArgs e)
   at System.Diagnostics.Process.OnExited()
   at System.Diagnostics.Process.RaiseOnExited()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)