Я создал службу WCF с привязкой net.tcp, и мне удалось добавить ссылку на службу в консольное приложение без ошибок.Ошибка связи WCF net.tcp
После этого я пытаюсь самостоятельно разместить эту службу в своем консольном приложении. Хост службы открывается, но когда я вызываю метод в службе со ссылочным объектом службы, я получаю это исключение
«Не удалось подключиться к net.tcp: // localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2 /. Попытка подключения продолжалась в течение промежутка времени 00: 00: 02.0800000. Код ошибки 10061 TCP: соединение не может быть выполнено, потому что целевая машина активно отказала ему [:: 1]: 808. '
Это мой CS-код файла
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
Может ли одна просьба помочь мне в этом.
Конфигурация вашего клиента имеет URL как net.tcp: // localhost/Design_Time_Addresses/MyWCFServiceLibrary/Service2 /, тогда как ваша служба находится на net.tcp: // localhost: 8732/Design_Time_Addresses/MyWCFServiceLibrary/Service2 /. Номер PORT отсутствует – Rajesh