Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Gu.Wpf.UiAutomation/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,18 @@ public static bool TryAttach(ProcessStartInfo processStartInfo, OnDispose onDisp
}

var running = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(exeFileName))
.FirstOrDefault(x => x.StartInfo.Arguments == processStartInfo.Arguments);
.FirstOrDefault(x =>
{
try
{
return x.StartInfo.Arguments == processStartInfo.Arguments;
}
catch (InvalidOperationException)
{
// This can happen for processes that we didn't start
return false;
}
});

if (running is { })
{
Expand Down