Today, an exception suddenly occurred while debugging the service. The error message is: "HTTP cannot register URL http: // +/temporary_listen_addresses/144ff7cb-10a4-4836-b76a-1a516da4ebda/because another application is using TCP port 80. "
It turns out that the default port 80 has been occupied by other programs. Therefore, an exception is thrown when the default binding endpoint is set for the WCF Service.
The solution is as follows:
Set the bound address in the client code. The Code is as follows:
Instancecontext = new instancecontext (New callbackhandler ());
VaR client = new servicereference2.calculatorclient (instancecontext );
Wsdualhttpbinding Ws = (wsdualhttpbinding) client. endpoint. binding;
WS. clientbaseaddress = new uri (http: // localhost: 30001/); // set the bound address
Console. writeline ("press <enter> to terminate client once the output is displayed .");
Console. writeline ();
Double value1 = 100.00d;
Client. addto (value1 );
Client. Clear ();
Console. Readline ();
Client. Close ();
In addition, you can change the service configuration file of the client and set the bound address. As follows:
<Bindings>
<Wsdualhttpbinding>
<Binding name = "wsdualhttpbinding_icalculator" clsetimeout = "00:01:00" clientbaseaddress = "http: // localhost: 30001 /"
Opentimeout = "00:01:00" receivetimeout = "00:10:00" sendtimeout = "00:01:00"
Bypassproxyonlocal = "false" transactionflow = "false" hostnamecomparisonmode = "strongwildcard"
Maxbufferpoolsize = "524288" maxcompute edmessagesize = "65536"
Messageencoding = "text" textencoding = "UTF-8" usedefaultwebproxy = "true">
<Readerquotas maxdepth = "32" maxstringcontentlength = "8192" maxarraylength = "16384"
Maxbytesperread = "4096" maxnametablecharcount = "16384"/>
<Reliablesession ordered = "true" inactivitytimeout = "00:10:00"/>
<Security mode = "message">
<Message clientcredentialtype = "Windows" negotiateservicecredential = "true"
Algorithmsuite = "default"/>
</Security>
</Binding>
</Wsdualhttpbinding>
</Bindings>
In this way, the service is normal.