使用 TCP 在 Windows 服务中托管 WCF
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论