Try using this constructor for the mutex -
Mutex Constructor (System.Threading) | Microsoft Docs[
^] and checking the return before proceeding e.g. (NB not tested)
bool createdNew;
mutex = new Mutex(true, "77aca664-ba25-4964-bc05-d7ba57030720", out createdNew);
if(!createdNew)
{
...etc
Also the scope of
mutex
is your
OnStartup
method which means you will be disposing of the mutex on exit of that function - try declaring it as a private member of the Application class e.g.
public partial class App : Application
{
private Mutex mutex = null;
protected override void OnStartup(StartupEventArgs e)
{
... etc