使用WsDualHttpBinding时tcp 80端口被占用

在WCF中,使用回调时一般采用NetTcp和WsDualHttp两种绑定。这两种绑定在Windows Server环境下没有什么问题。但是在Xp SP2下,使用默认WsDualHttp绑定时,会出现下面的错误:

AddressAlreadyInUseException: HTTP could not register URL http://+:80/myService/ because TCP port 80 is being used by another application.

这是因为,在默认情况下,回调接口会使用80端口,而80端口已经被IE浏览器占用。解决的办法主要有以下两个:

1、停止使用IIS(using “net stop w3svc”)

2、修改客户端的回调接口地址。使用clientBaseAddress属性。

如代码方式:

binding.ClientBaseAddress = "http://localhost:8000/myClient/"

或者配置文件方式:

<wsDualHttpBinding clientBaseAddress="http://localhost:8000/myClient/"/>

原文地址:https://www.cnblogs.com/jyz/p/1437964.html