0
我有一個WCF服務運行正常,如果我在IIS中添加對它的引用時,但是當我嘗試在win應用程序客戶端中託管它時應用程序無法找到它。這隻發生在我使用NetTcpBinding時。我得到錯誤「沒有端點監聽net.tcp:// localhost:5566 /可以接受該消息」。當我使用basicHttpBinding時,一切正常。添加服務引用到NetTcpBinding在win應用程序中託管的wcf服務的問題
這裏的服務
<system.serviceModel>
<services>
<service name="TestWcfService.Service1" behaviorConfiguration="TestWcfService.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="netTcpBinding" contract="TestWcfService.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestWcfService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="false"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
配置文件,這裏從主機應用程序的代碼
ServiceHost host = new ServiceHost(typeof(Service1), new Uri("net.tcp://localhost:5566"));
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = false;
host.Description.Behaviors.Add(behavior);
host.AddServiceEndpoint(typeof(IService1), new NetTcpBinding(), "Service1");
host.AddServiceEndpoint(typeof(IMetadataExchange), new NetTcpBinding(), "MEX");
host.Open();