没有WCF服务主机,具有WCF命名管道的Windows服务不起作用

时间:2014-11-22 20:23:56

标签: c# .net windows wcf service

我在C#中使用命名管道部分地根据these instructions制作Windows服务,而是使用命名管道WCF TCP。我使用.NET framework 4.5,Visual Studio 2013和OS MS Windows 8.1 x64。当我使用WCF服务主机时,一切正常。但是我需要直接使用已安装的Windows服务。如果我在WCF项目属性中关闭WCF服务主机,我会收到此错误:

  

未处理的类型异常   mscorlib.dll中发生System.ServiceModel.EndpointNotFoundException        附加信息:net.pipe:// localhost / Service5上没有可以接受该消息的端点。这是   通常由不正确的地址或SOAP操作引起。看到   InnerException(如果存在),以获取更多详细信息。

WindowsService和WcfService项目的App.config是:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- 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="WcfServiceLibrary5.Service5">
        <endpoint address="" binding="netNamedPipeBinding" bindingConfiguration=""
          contract="WcfServiceLibrary5.IService5">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.pipe://localhost/Service5" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

TestClient的App.config是:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <netNamedPipeBinding>
                <binding name="NetNamedPipeBinding_IService5" />
            </netNamedPipeBinding>
        </bindings>
        <client>
            <endpoint address="net.pipe://localhost/Service5" binding="netNamedPipeBinding"
                bindingConfiguration="NetNamedPipeBinding_IService5" contract="ServiceReference1.IService5"
                name="NetNamedPipeBinding_IService5">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

请问哪里有问题?谢谢您的帮助。

0 个答案:

没有答案