I'm baffled by this, can someone tell me why, when I call:
using (Mutex mtx = new Mutex(false, strId))
{
}
I get this exception:
Could not find a part of the path.
If strId
is set to something like localhost\SQLEXPRESS-MyName-2
?
I'm baffled by this, can someone tell me why, when I call:
using (Mutex mtx = new Mutex(false, strId))
{
}
I get this exception:
Could not find a part of the path.
If strId
is set to something like localhost\SQLEXPRESS-MyName-2
?
From the docs:
Because you are using a backslash in your name (
\
) it assumes you are trying to specify a visibility level, and then discoverslocalhost
isn't a valid visibility level - hence generating the exception.It's rather strange the .NET docs don't mention explicitly
\
is a reserved character in Mutex names, the Win32 docs do explain it better (link):