【问题标题】:PipeException on local WCF service本地 WCF 服务上的 PipeException
【发布时间】:2022-01-07 02:42:15
【问题描述】:

我目前正在将一个 winforms 应用程序迁移到 WPF,我需要做的最后一件事是迁移 WCF 服务

配置文件发送方:

<behaviors>
  <serviceBehaviors>
    <behavior name="NetPipeBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="MyLibrary.WcfServiceController.GuiController" behaviorConfiguration="NetPipeBehavior">
    <endpoint address="" binding="netNamedPipeBinding" contract="MyLibrary.WcfServiceController.IGuiController" />
    <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.pipe://localhost/GUI-ORG/" />
      </baseAddresses>
    </host>
  </service>
</services>

客户端:

<bindings>
  <netNamedPipeBinding>
    <binding name="NetNamedPipeBinding_IGuiController"/>
  </netNamedPipeBinding>
</bindings>
<client>
  <endpoint address="net.pipe://localhost/GUI-ORG/" binding="netNamedPipeBinding"
            bindingConfiguration="NetNamedPipeBinding_IGuiController"
            contract="GuiUpdaterReference.IGuiController" name="NetNamedPipeBinding_IGuiController">
  </endpoint>
</client>

我有一个看起来像这样的包装器:

public class GuiControllerClientWrapper
{
    private readonly LaunchType _launchType;
    private readonly GuiUpdaterReference.IGuiController _gc;

    public GuiControllerClientWrapper(LaunchType launchType)
    {
        _errorSent = false;
        _launchType = launchType;
        _gc = new GuiControllerClient();
        if (launchType == LaunchType.Manual)
        {
            ((GuiControllerClient)_gc).Open();
        }
    }

    /* other functions */
}

调用Open()时出现异常:EndpointNotFoundException: There was no endpoint listening at "net.pipe://localhost/GUI-ORG" that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

InnerException 如下:The pipe endpoint 'net.pipe://localhost/GUI-ORG' could not be found on your local machine

然后一个堆栈跟踪指向我的包装器调用打开函数

问题是,如果我在项目中添加旧的 winforms GUI 并重新安装所有内容,它确实可以工作,发送消息并且一切正常

我试过了

  • 使用诊断,但它没有提供任何我可以使用的信息
  • 更改地址
  • 重新创建/更新服务引用

我错过了什么?

【问题讨论】:

    标签: c# .net wcf


    【解决方案1】:

    检查“Net.Pipe Listener Adapter”服务是否在服务管理控制台中运行。

    Start Windows service -> Net.Pipe Listener Adapter service 
    

    No endpoint listening at net.pipe

    【讨论】:

    • 感谢您的回答,但我发现了问题。请检查我的答案
    【解决方案2】:

    发现了问题,即使异常可以帮助我,也不是 WCF 的错误

    我有一个服务窗口,每天运行一些代码来检查本地 AD 并做一些事情 我还有一个 GUI,可以让我控制服务并手动启动处理

    单击按钮时,会在客户端启动一个端点(通过进度条进行更新),但我不知道 WPF 在后台工作人员访问主线程时引发异常(在WinForms)。

    我的后台工作人员会启动,读取数据源然后崩溃,直接进入关闭端点的RunWorkerCompleted 事件

    这是 WCF 可以帮助我更多的地方:当我开始与后台工作人员混在一起时,异常发生了变化,现在它告诉我通信通道已过早关闭

    我的代码现在使用对 UI 线程的安全访问,这使通道在必要时保持活动状态

    【讨论】:

      猜你喜欢
      • 2012-08-09
      • 2018-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多