简体   繁体   English

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

[英]Named Pipes Binding Working in Windows Service, but BasicHttp Binding Failing

I am trying to build a windows service hosted WCF service with http and named pipes endpoints. 我正在尝试使用http和命名管道端点构建Windows服务托管的WCF服务。 When I have configured it to use named pipes, it is working fine, but when I try to configure it to use http binding it all compiles and installs, but when I try to start the service, it stops immediately, and I can't find an error message in the Event Viewer. 当我将其配置为使用命名管道时,它可以正常工作,但是当我尝试将其配置为使用http绑定时,它将全部编译并安装,但是当我尝试启动该服务时,它会立即停止,并且我无法在事件查看器中找到错误消息。

This is my app.config file. 这是我的app.config文件。 The config in comments works, the config without comments doesn't. 注释中的配置有效,没有注释的配置无效。

<?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 demonstrates hosting a http endpoint using a windows service, and I think my config looks correct. 该MSDN教程演示了使用Windows服务托管http终结点,我认为我的配置看起来正确。

Any suggestions on how to proceed would be welcome. 任何有关如何进行的建议都将受到欢迎。

It turns out that the answer was actually to do with the account the service was running under. 事实证明,答案实际上与服务在其下运行的帐户有关。 Having followed a (different) tutorial for running a named pipes endpoint in the windows service, the service was installed running as the NetworkService service account, where it needs to be running under the LocalSystem account to work correctly. 在按照(不同的)教程在Windows服务中运行命名管道终结点之后,该服务以NetworkService服务帐户的身份运行,该服务需要在LocalSystem帐户下运行才能正常工作。 Thanks to Tim for the suggestion. 感谢蒂姆的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM