NamedPipeClientStream在app服务中不起作用

时间:2016-11-06 15:21:46

标签: c# azure pipe

我的代码在我的服务器上运行良好但在azure app服务中我收到此错误“操作已超时”。在enter code here

 pipeStream.Connect(TimeOut);

我的代码

public void Send(string SendStr, string PipeName, int TimeOut = 1000)
    {
        try
        {
            NamedPipeClientStream pipeStream = new NamedPipeClientStream(".", PipeName, PipeDirection.Out, PipeOptions.Asynchronous);

            // The connect function will indefinitely wait for the pipe to become available
            // If that is not acceptable specify a maximum waiting time (in ms)
            pipeStream.Connect(TimeOut);
            Debug.WriteLine("[Client] Pipe connection established");

            byte[] _buffer = Encoding.UTF8.GetBytes(SendStr);
            pipeStream.BeginWrite(_buffer, 0, _buffer.Length, AsyncSend, pipeStream);
        }
        catch (TimeoutException oEX)
        {
            Debug.WriteLine(oEX.Message);
        }
    }

1 个答案:

答案 0 :(得分:0)

经过大量工作,它几乎完全解决了我的问题 http://stackoverflow.com/a/3478552/5996253