Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Csharp命名管道服务器连接问题_C#_Pipe_Named - Fatal编程技术网

C# Csharp命名管道服务器连接问题

C# Csharp命名管道服务器连接问题,c#,pipe,named,C#,Pipe,Named,我在远程计算机上有一个服务器,当我连接到管道时,它将不允许我连接,直到我在服务器端重新启动计算机。随机测试可能会在几周后进行。我将max-instance属性放在服务器端。有什么想法吗?我还检查了前一个连接是否已关闭,并且似乎已关闭,因为我在客户端显示了实例数。下面是用于服务器端的代码 public void ProcessNextClientServiceApp() { ps = new PipeSecurity(); ps.AddAccessR

我在远程计算机上有一个服务器,当我连接到管道时,它将不允许我连接,直到我在服务器端重新启动计算机。随机测试可能会在几周后进行。我将max-instance属性放在服务器端。有什么想法吗?我还检查了前一个连接是否已关闭,并且似乎已关闭,因为我在客户端显示了实例数。下面是用于服务器端的代码

public void ProcessNextClientServiceApp()
{
            ps = new PipeSecurity();
            ps.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow));
            ps.AddAccessRule(new PipeAccessRule("CREATOR OWNER", PipeAccessRights.FullControl, AccessControlType.Allow));
            ps.AddAccessRule(new PipeAccessRule("SYSTEM", PipeAccessRights.FullControl, AccessControlType.Allow));
            pipeStream = new NamedPipeServerStream(PipeName, PipeDirection.InOut, NamedPipeServerStream.MaxAllowedServerInstances, PipeTransmissionMode.Message, PipeOptions.None, 1024, 1024, ps);
                Console.WriteLine("Waiting...");
                pipeStream.WaitForConnection();

                PassClient(pipeStream);
    }


    public void PassClient(NamedPipeServerStream pipeStream)
    {
        var thread = new Thread(() =>
        {
                while (pipeStream.IsConnected){}

            CloseNamedPipe();
            
        });
        thread.IsBackground = true;
        thread.Start();
    }