命名管道绑定在Windows服务中工作,但BasicHttp绑定失败

时间:2015-05-11 13:17:11

标签: c# wcf service

我正在尝试使用http和命名管道端点构建一个Windows服务托管的WCF服务。当我将它配置为使用命名管道时,它工作正常,但是当我尝试将其配置为使用http绑定时,它都会编译和安装,但是当我尝试启动服务时,它立即停止,我可以&#39 ; t在事件查看器中找到错误消息。

这是我的app.config文件。注释中的配置有效,没有注释的配置没有。

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

  <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="NogginWcf.NogginWcfSvc">
      <endpoint address="" binding="basicHttpBinding"
        bindingConfiguration="" name="BasicHttp" bindingName="BasicHttp"
        contract="NogginWcf.INogginWcfSvc" />
      <endpoint address="mex"
        binding="mexHttpBinding" bindingConfiguration="" name="HttpMex"
        bindingName="HttpMex" contract="IMetadataExchange" />
      <!--<endpoint address="" binding="netNamedPipeBinding"
        bindingConfiguration="" name="NamedPipes" bindingName="NamedPipes"
        contract="NogginWcf.INogginWcfSvc" />
      <endpoint address="mex"
        binding="mexNamedPipeBinding" bindingConfiguration="" name="NamedPipesMex"
        bindingName="NamedPipesMex" contract="IMetadataExchange" />-->
      <host>
        <baseAddresses>
          <!--<add baseAddress="net.pipe://localhost/NogginPipesService" />-->
          <add baseAddress="http://localhost:8000/NogginHttpService" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpGetEnabled="false" />
        <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
</configuration>

This MSDN tutorial演示使用Windows服务托管http端点,我认为我的配置看起来是正确的。

欢迎任何有关如何进行的建议。

1 个答案:

答案 0 :(得分:0)

事实证明,答案实际上与服务运行的帐户有关。在Windows服务中遵循(不同)教程运行命名管道端点后,该服务作为NetworkService服务帐户运行,需要在LocalSystem帐户下运行才能正常工作。感谢Tim提出建议。

相关问题