【发布时间】:2010-12-30 02:47:43
【问题描述】:
public static void StartService()
{
Hashtable t = new Hashtable();
t["port"] = portnumber;
t["name"] = "somechannel";
channel= new TcpChannel(t, null, null);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(someRemoteObject), "somedomain", WellKnownObjectMode.SingleCall);
}
public static void StopService()
{
//what should I do ??
}
buttonStart_Click:调用StartService()buttonStop_Click:调用StopService()
很明显,点击buttonStart两次会导致“每个套接字地址(协议/网络地址/端口)通常只允许使用一次”异常。
问题是如何在不终止应用程序的情况下停止响应远程调用。
【问题讨论】:
-
这看起来像是在编写新代码。如果是这样,您最好放弃 Remoting 并深入研究 WCF。
-
您在哪里启动、停止和重新启动远程处理的功能是什么?为什么不在应用程序的生命周期内建立连接而只使用一个连接?
-
.Net remoting 是一种让服务进行通信的简单方法,如果 WCF 真的是解决他的问题的更好解决方案,这取决于他想要实现的目标。
-
WCF 也很简单。它还有一个不会过时的额外优势。
-
问题是如何在不终止应用程序的情况下停止响应远程调用。