代码人生的小狗窝

一行行枯燥的代码,却描绘出人生的点点滴滴

您现在的位置是:首页>_C#

请大家帮帮忙,remoting 服务器半闭重起后客户怎么处理?重新注册时出错了。

发布时间:2019-11-21浏览(1590)

    请大家帮帮忙,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");
       
      }
      [/code]
      出现异常:未处理的NotSupportedExcepaction 不支持所指定的方法。由于以前的函数求值超时,函数求值被禁用,必须继续执行才能启用函数求值