问题:NamedPipeClientStream对象调用Connect(毫秒)时报“访问路径被拒绝”
解决:
在服务端(NamedPipeServerStream)中添加PipeSecurity对象
SecurityIdentifier securityIdentifier = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
PipeSecurity pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(new PipeAccessRule(securityIdentifier, PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow));
NamedPipeServerStream stream = = new NamedPipeServerStream("管道名", PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.None, 0, 0, pipeSecurity);
参考连接
https://stackoverflow.com/questions/59969943/how-to-set-pipesecurity-of-namedpipeserverstream-in-net-core/71370760#71370760
https://learn.microsoft.com/zh-cn/dotnet/api/system.security.principal.wellknownsidtype?view=net-8.0