【问题标题】:WCF Named Pipe Another Endpoint Error but no other endpoints?WCF命名管道另一个端点错误但没有其他端点?
【发布时间】:2021-08-22 02:12:42
【问题描述】:

我正在使用DuplexChannelFactorynet.pipe://localhost/test 上创建命名管道。但是,当我运行我的程序时,我得到一个错误:Cannot listen on pipe name "net.pipe://localhost/" because another pipe endpoint is already listening on that name.

所以我试图通过打开一个powershell并输入[System.IO.Directory]::GetFiles("\\.\\pipe\\)来查看是否真的如此,但没有提及localhost。

然后我也尝试将地址net.pipe://localhost/test更改为net.pipe://anything/test,但还是不行。

最后我重新启动了计算机并且它工作了。但是重启电脑不是最优的,我今天早些时候又重启了一次,它又坏了。

我会收到此错误还有其他原因吗?

【问题讨论】:

    标签: c# .net wcf named-pipes .net-3.0


    【解决方案1】:

    WCF 命名管道在与常规命名管道不同的系统上运行。当您在 localhost 上打开常规命名管道时,您将在 \.\pipe\localhost 处获得一个管道,但当您打开 WCF 管道时,您将获得 \.\pipe\some-guid-xxxx-xxxx。此生成的 GUID 对于同名的 WCF 命名管道是一致的,这就是它无缝工作的原因。 (见Prevent Named Pipes Conflict

    现在,在我的代码中,我想在localhost 上创建一个命名管道。它没有出现在 [System.IO.Directory]::GetFiles("\\.\\pipe\\) 中,因为 WCF 使用 UUID。

    我最后使用的解决方法是将管道url指定为net.pipe\localhost\something_specific_to_me并有一个额外的AddServiceEndpoint(...,"something_else"),以便最终的管道可以通过net.pipe\localhost\something_specific_to_me\something_else连接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-11
      • 1970-01-01
      • 2016-09-22
      • 1970-01-01
      • 2014-09-01
      相关资源
      最近更新 更多