NamedPipeClientStream can not access to NamedPipeServerStream under session 0

Looks like the problem was in security settings here:

System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.BuiltinUsersSid, null);

Should be :

System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);

Thanks microsoft communnity


I know this question is old bit I just ran across this issue and figured I'd add to it.

This error can also indicate that the named pipe is already in use. I had a production service running of the same executable that I was trying to debug, and when initializing that pipe server it failed because it was already in use by another process. Seems like the error should be a little more informative of a situation like this, but it is what it is.