使用 TCP 在 Windows 服务中托管 WCF

发布于 2024-12-08 02:37:44 字数 1718 浏览 1 评论 0原文

我正在尝试在 Windows 2008 x64 上的 Windows 服务中托管 wcf 服务(tcp)。

我首先作为主持人制作了一个正常的程序,效果很好。

然后我使用相同的配置创建了一个 Windows 服务:
http://msdn.microsoft.com/en-us/library/ff649818.aspx

服务器安装良好,启动没有问题,但我无法连接到它。
我认为该程序未加载配置文件(exename.config),因为 myServiceHost.BaseAddresses 为空。

知道什么可能导致此错误或者我如何找到错误?

这是我的配置:

<?xml version="1.0"?>

<configuration>

  <system.web>
    <compilation debug="false" />
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="SlmWcfServiceLibrary.Service1Behavior" name="SlmWcfServiceLibrary.SlmService">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="SlmWcfServiceLibrary.ISlmService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:9999/Service1/" />
      </baseAddresses>
    </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
    <behavior name="SlmWcfServiceLibrary.Service1Behavior">
      <serviceMetadata httpGetEnabled="False" />
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

  <startup></startup>
</configuration>

I'm trying to host a wcf service (tcp) in a windows service on Windows 2008 x64.

I first made a normal program as host and that works fine.

I then made a windows service with the same config:
http://msdn.microsoft.com/en-us/library/ff649818.aspx

The server installed fine en starts without a problem, but I can't connect to it.
I think the program isn't loading the config file (exename.config) because myServiceHost.BaseAddresses is empty.

Any idea what could cause this or how I can find the error?

Here is my config:

<?xml version="1.0"?>

<configuration>

  <system.web>
    <compilation debug="false" />
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="SlmWcfServiceLibrary.Service1Behavior" name="SlmWcfServiceLibrary.SlmService">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="SlmWcfServiceLibrary.ISlmService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:9999/Service1/" />
      </baseAddresses>
    </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
    <behavior name="SlmWcfServiceLibrary.Service1Behavior">
      <serviceMetadata httpGetEnabled="False" />
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

  <startup></startup>
</configuration>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文