请大家帮帮忙,remoting 服务器半闭重起后客户怎么办?重新注册时出错了。急急急急急急急急急!!!!!!!!!!!!!!!!!!!
服务器是Windows服务器,有N个客户端,互相定阅事件传递消息。
注册方法
C# code
private void regRemoteService()
{
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
TcpChannel tcpChannel = null;
try
{
props["name"] = "YuHaiYang";
props["bindTo"] = this.objDBAgentApplication.RemotingIp;
props["port"] = this.objDBAgentApplication.LocalHostPort;
props["rejectRemoteRequests"] = false;
tcpChannel = new TcpChannel(props, clientProvider, serverProvider);
}
catch
{
//重新连接时让系统自选端口
props["name"] = "YuHaiYang";
props["bindTo"] = this.objDBAgentApplication.RemotingIp;
props["port"] = 0;
props["rejectRemoteRequests"] = false;
tcpChannel = new TcpChannel(props, clientProvider, serverProvider);
}
ChannelServices.RegisterChannel(tcpChannel, false);
this.eventWrapper = new EventWrapper();
this.iGpsRemote = (IGpsRemote)Activator.GetObject(typeof(IGpsRemote), "tcp://" + this.objDBAgentApplication.RemotingIp + ":" + this.objDBAgentApplication.RemotingPort + "/GPSRemoteServer.soap");
}
当Windows服务重起后,客户端定阅的事件就不能再收到消息,重新注册服务器 再调用regRemoteService方法出错
private void regRemoteService()
{
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
TcpChannel tcpChannel = null;
try
{
props["name"] = "YuHaiYang";
props["bindTo"] = this.objDBAgentApplication.RemotingIp;
props["port"] = this.objDBAgentApplication.LocalHostPort;
props["rejectRemoteRequests"] = false;
tcpChannel = new TcpChannel(props, clientProvider, serverProvider);
}
catch
{
//重新连接时让系统自选端口
props["name"] = "YuHaiYang";
props["bindTo"] = this.objDBAgentApplication.RemotingIp;
props["port"] = 0;
props["rejectRemoteRequests"] = false;
tcpChannel = new TcpChannel(props, clientProvider, serverProvider);//这里报错
}
ChannelServices.RegisterChannel(tcpChannel, false);
this.eventWrapper = new EventWrapper();
this.iGpsRemote = (IGpsRemote)Activator.GetObject(typeof(IGpsRemote), "tcp://" + this.objDBAgentApplication.RemotingIp + ":" + this.objDBAgentApplication.RemotingPort + "/GPSRemoteServer.soap");