![](/img/trans.png)
[英]Getting a PipeException (pipe is closing) with a WCF service that uses NamedPipesBinding
[英]PipeException on local WCF service
我目前正在将一个 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.
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
然后指向我的包装器的堆栈跟踪调用打开的 function
问题是,如果我在项目中添加旧的 winforms GUI 并重新安装所有内容,它确实可以工作,发送消息并且一切正常
我努力了
我错过了什么?
检查“Net.Pipe Listener Adapter”服务是否在服务管理控制台中运行。
Start Windows service -> Net.Pipe Listener Adapter service
发现了问题,即使异常可以帮助我,也不是 WCF 有错
我有一个服务 windows 每天运行一些代码来检查本地 AD 并做一些事情我还有一个 GUI 允许我控制服务并手动启动处理
单击该按钮时,会在客户端上启动一个端点(通过进度条进行更新),但我不知道 WPF 在后台工作人员访问主线程时引发异常(在 WinForms 中不是这种情况)。
我的后台工作人员将启动,读取数据源然后崩溃,直接进入关闭端点的RunWorkerCompleted
事件
这是 WCF 可以帮助我更多的地方:当我开始与后台工作人员相处时,异常发生了变化,现在它告诉我通信通道过早关闭
我的代码现在使用对 UI 线程的安全访问,这使通道在必要时保持活动状态
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.