[英]Stop .Net Remoting
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
導致“通常只允許使用每個套接字地址(協議/網絡地址/端口)一次”的例外。
問題是如何在不終止應用程序的情況下停止響應遠程呼叫。
您如何在第一次調用buttonStart_Click時設置一個標志,如果設置了標志,則跳過遠程處理?
嘗試
ChannelServices.UnregisterChannel(channel);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.