![](/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.