【发布时间】:2011-10-02 17:39:49
【问题描述】:
我在配置和启动 WCF 服务时遇到问题。 在我的应用程序中有一个启动服务的方法。像这样的
void Start(string protocol, string address, string port)
{
host = new ServiceHost(_myService,
new Uri(String.Format("{0}://{1}{2}/Sample", protocol, address, port)));
//...Some configuration (bindings, behaviors, etc.)
host.Open();
}
让我的电脑有一个 IP 192.168.0.1。当我传递值为 '192.168.0.2' 的 'address' 参数时,发生错误
"A TCP error (10049: The requested address is not valid in its context.)
occurred while listening on IP Endpoint=192.168.0.2:1234"
没错,因为它不是我的 IP。但在那之后,如果我传递正确的值(我的真实 IP),我会收到关于 IP 192.168.0.2 的相同错误!所以我无法在不重新启动应用程序的情况下重新配置和重新启动服务器。
为什么会这样?我怎样才能避免这种行为?
【问题讨论】:
标签: c# .net wcf configuration