我有兩個不同的進程(在同一個會話上,兩個都沒有提升)在自託管服務(託管在服務器進程中)上使用命名管道進行通信。 在極少數情況下(2-3%的用戶),客戶端將無法連接服務器。WCF命名管道未知錯誤
它只發生在UAC下,並沒有提升。要清楚的是,在大多數情況下,應用程序對於使用UAC和未升級會話的用戶來說工作得很好。
我發現,作爲管理員運行所有內容可以解決此問題,但我不想走這條路。另外,將通信改爲netTcp也可以解決它,但它會提示我的用戶使用Windows防火牆對話框,這對我來說是不可接受的。
我不明白爲什麼發生這種情況或如何解決它。我看到很多關於創建管道所需權限的文章,但就我所見,我不需要全局管道,只需要一個本地管道,而不需要UAC off/elevation /特定對象。
服務器將不顯示錯誤,通常採取行動,但客戶端將顯示此:
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at net.pipe://localhost/MyAppServices that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Server stack trace:
at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at MyApp.BL.Interfaces.Service.IWCFClientServiceAPI.Initialize()
at MyApp.Main.attemptConnection(WCFStoreAPIClient& i_WCFClientServiceAPI, IWCFClientCallbackAPI& i_WCFClientCallbackAPI)
服務器配置:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="MyApp.Client.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Locales"/>
</assemblyBinding>
</runtime>
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NPBinding_IWCFClientServiceAPI" transactionProtocol="OleTransactions" receiveTimeout="infinite" maxConnections="200" maxBufferSize="3145728" maxBufferPoolSize="3145728" maxReceivedMessageSize="3145728"/>
</netNamedPipeBinding>
</bindings>
<services>
<service
name="MyApp.Client.Core.Managers.WCFClientService"
behaviorConfiguration="WCFClientServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/MyAppServices/" />
</baseAddresses>
</host>
<endpoint address="" binding="netNamedPipeBinding" contract="MyApp.BL.Interfaces.Service.IWCFClientServiceAPI" bindingConfiguration="NPBinding_IWCFClientServiceAPI">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFClientServiceBehavior">
<serviceMetadata httpGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
客戶端配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NPBinding_IWCFClientServiceAPI" transactionProtocol="OleTransactions" receiveTimeout="infinite" maxConnections="200" maxBufferSize="3145728" maxBufferPoolSize="3145728" maxReceivedMessageSize="3145728"/>
</netNamedPipeBinding>
</bindings>
<client>
<endpoint address="net.pipe://localhost/MyAppServices"
binding="netNamedPipeBinding"
bindingConfiguration="NPBinding_IWCFClientServiceAPI"
contract="MyApp.BL.Interfaces.Service.IWCFClientServiceAPI"
name="NPBinding_IWCFClientServiceAPI">
<headers>
<ClientIdentification>MyAppStore</ClientIdentification>
</headers>
</endpoint>
</client>
</system.serviceModel>
</configuration>
你確定你已經啓用net.pipe綁定在iis網站上的服務託管? – 2015-02-08 17:09:22
該服務是自託管的。我會更新我的帖子。 – Tsury 2015-02-08 17:10:58