簡體   English   中英

WCF net.pipe://localhost/Ivan.WCFService.Lib/Service1 沒有可以接受消息的端點

[英]WCF There was no endpoint listening at net.pipe://localhost/Ivan.WCFService.Lib/Service1 that could accept the message

我在windows服務中托管了一個WCF服務,實現同一台電腦上的跨進程訪問。 因此,采用了netNamedPipBinding。 現在,在我的開發 PC 中一切正常(客戶端可以通過端點訪問 wcf 服務)。 但是當我將client.exe、host.exe和wcf.dll復制到另一台PC進行測試時。 它不能工作並拋出這樣的異常:

System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at net.pipe://localhost/Ivan.WCFService.Lib/MyService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.IO.PipeException: The pipe endpoint 'net.pipe://localhost/Ivan.WCFService.Lib/MyService' could not be found on your local machine.
   --- End of inner exception stack trace ---

Server stack trace:
   at System.ServiceModel.Channels.PipeConnectionInitiator.GetPipeName(Uri uri, IPipeTransportFactorySettings transportFactorySettings)
   at System.ServiceModel.Channels.NamedPipeConnectionPoolRegistry.NamedPipeConnectionPool.GetPoolKey(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.CommunicationPool`2.TakeConnection(EndpointAddress address, Uri via, TimeSpan timeout, TKey& key)
   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.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 Ivan.WCFService.Client.MyServiceReference.IMyService.QueryLinks()
   at Ivan.WCFService.Client.MyServiceReference.MyServiceClient.QueryLinks() in line 2547

所以這里有問題:

  1. 有沒有遺漏的文件要復制。
  2. 異常指向端點。 這是我的 wcf 服務庫配置文件。
<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="Ivan.WCFService.Lib.MyService">
        <endpoint address="MyService" binding="netNamedPipeBinding" contract="Ivan.WCFService.Lib.IMyService"/>
        <endpoint address="MyService/mex" binding="mexNamedPipeBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="net.pipe://localhost/Ivan.WCFService.Lib"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="False" httpsGetEnabled="False"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>

在我的情況下,我不確定 baseAddress 是否應該由“localhost”設置。 並發布客戶端配置文件。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
    <add key="ClientSettingsProvider.ServiceUri" value=""/>
  </appSettings>
  <system.web>
    <compilation debug="true"/>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
      </providers>
    </roleManager>
  </system.web>
    <system.serviceModel>
        <bindings>
            <netNamedPipeBinding>
              <binding name="NetNamedPipeBinding_IMyService" >
                <security mode="Transport">
                  <transport protectionLevel="EncryptAndSign" />
                </security>
              </binding>
            </netNamedPipeBinding>
        </bindings>
        <client>
            <endpoint address="net.pipe://localhost/Ivan.WCFService.Lib/MyService"
                binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IMyService"
                contract="MyServiceReference.IMyService" name="NetNamedPipeBinding_IMyService">
            </endpoint>
        </client>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
  1. Win10平台安全因素會影響這樣的端點嗎?(已經以管理員身份運行)
  2. 已經開啟net.pip Listener Adapter服務,狀態為running。 總之,這對配置文件可以在我的開發 PC 中正常運行。 當我嘗試在其他 PC 上測試它時,它不會拋出任何端點異常。 有人可以幫忙嗎?

你需要修改baseAddress:

           <endpoint address="net.pipe://The IP address of the WCF server/Ivan.WCFService.Lib/MyService"
                binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IMyService"
                contract="MyServiceReference.IMyService" name="NetNamedPipeBinding_IMyService">
            </endpoint>

如果客戶端和服務器在同一台機器上,我們可以使用 localhost。 如果客戶端和服務器不在同一台機器上,我們需要修改客戶端的端點地址。 如果此時客戶端的訪問端點地址還是 localhost 會報錯。

需要修改客戶端的endpoint地址,使其與WCF服務器的IP地址一致,然后重新編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM