WCF net.tcp通信错误
我使用net.tcp绑定创建了一个WCF服务,并且能够在控制台应用程序中添加对它的服务引用,而不会出现错误 完成此操作后,我将尝试在我的控制台应用程序中自行托管此服务。服务主机被打开,但是当我使用服务引用对象调用服务中的方法时,我得到了这个异常 '无法连接到网络。tcp://localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2/. 连接尝试持续的时间跨度为00:00:02.0800000。TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它[::1]:808' 这是我的cs文件代码WCF net.tcp通信错误,wcf,exception,binding,net.tcp,Wcf,Exception,Binding,Net.tcp,我使用net.tcp绑定创建了一个WCF服务,并且能够在控制台应用程序中添加对它的服务引用,而不会出现错误 完成此操作后,我将尝试在我的控制台应用程序中自行托管此服务。服务主机被打开,但是当我使用服务引用对象调用服务中的方法时,我得到了这个异常 '无法连接到网络。tcp://localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2/. 连接尝试持续的时间跨度为00:00:02.0800000。TCP错误代码10061:无法建立连接,
Main method()
Service2Client sc2 = new Service2Client();
Uri baseaddress = new Uri("net.tcp://localhost:8732/Design_Time_Addresses/MyWCFServiceLibrary/Service2/");
ServiceHost serviceHost = new ServiceHost(typeof(Service2Client), baseaddress);
serviceHost.Open();
Console.WriteLine(sc2.GetData(124)); --> exception comes at this point
Console.ReadLine();
这是控制台应用程序中的app.config
<system.serviceModel>
<client>
<endpoint address="net.tcp://localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2/"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IService2"
contract="ServiceReference2.IService2" name="NetTcpBinding_IService2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService2" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<!--<client>
<endpoint address="net.tcp://localhost:8732/Design_Time_Addresses/MyWCFServiceLibrary/Service2/"
binding="netTcpBinding" bindingConfiguration="NewBinding0" contract="MyWCFServiceLibrary.IService2"
name="endpointClient" />
<endpoint address="net.tcp://localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2/"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IService2"
contract="ServiceReference2.IService2" name="NetTcpBinding_IService2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>-->
</system.serviceModel>
环境:Vs2010
有谁能帮我一下吗。有可能:
1) 防火墙正在阻止请求。看看吧
2) 确保
- Net.Tcp侦听器适配器李>
- Net.Tcp端口共享服务
- Net.Tcp侦听器适配器李>
- Net.Tcp端口共享服务
正在运行(Windows服务)您的客户端配置的URL为
net。tcp://localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2/
而你的服务是免费的
net。tcp://localhost:8732/Design_Time_Addresses/MyWCFServiceLibrary/Service2/
控制台应用程序客户端终结点元素的app.config中缺少端口号。客户端配置的URL为
net。tcp://localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2/
而你的服务是免费的
net。tcp://localhost:8732/Design_Time_Addresses/MyWCFServiceLibrary/Service2/
控制台应用程序客户端终结点元素的app.config中缺少端口号。您好,我认为这可能不是问题所在,因为该服务是我的机器的本地服务您启动应用程序的操作系统是什么?抱歉,我手头没有它。。。请在管理工具中的某个地方查找。也请查看我在回答中添加的服务。请对此提出任何建议。我认为这可能不是问题,因为该服务是我的机器的本地服务。您启动应用程序的操作系统是什么?抱歉,我手头没有它。。。在管理工具中的某个地方查找它。也可以查看我添加到答案中的服务。请对此提出任何建议。您的客户端配置的URL为net。tcp://localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2/ 而你的服务是在网上的。tcp://localhost:8732/Design_Time_Addresses/MyWCFServiceLibrary/Service2/. 端口号丢失客户端配置的URL为net。tcp://localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2/ 而你的服务是在网上的。tcp://localhost:8732/Design_Time_Addresses/MyWCFServiceLibrary/Service2/. 缺少端口号