Esempio n. 1
0
 //连接RMS远程服务程序
 public static bool ConnectSvr()
 {
     try
     {
         //客户端不需要定义通道
         //按指定的URI创建远程对象代理
         string RemoteRMSServerName = ReadStrfromReg("RemoteRMSServerName", "localhost");
         string RemoteRMSServerPort = ReadStrfromReg("RemoteRMSServerPort", "8023");
         svrobj = (CRmsSvr.CRMSServer)(Activator.GetObject(typeof(CRmsSvr.CRMSServer), "tcp://" + RemoteRMSServerName + ":" + RemoteRMSServerPort + "/RMSServer"));
         ////判断代理是否被创建,如果不成功,引发错误,否则调用服务方法
         //if (svrobj == null)
         //{
         //    MessageBox.Show("无法创建代理");
         //    return false;
         //}
         //else
         //{
         //    //创建成功
         //    //MsgBox("建立代理成功")
         //    return true;
         //}
         return true;
     }
     catch (Exception e)
     {
         MessageBox.Show("无法创建代理:"+e.Message);
     }
     return false;
 }
Esempio n. 2
0
 //连接RMS远程服务程序
 public static bool ConnectSvr()
 {
     try
     {
         //错误处理
         //On Error Goto Errorhandler VBConversions Warning: On Error Goto not supported in C#
         //客户端不需要定义通道
         //按指定的URI创建远程对象代理
         svrobj = (CRmsSvr.CRMSServer)(Activator.GetObject(typeof(CRmsSvr.CRMSServer), "tcp://" + ReadStrfromReg("RemoteRMSServerName", "localhost") + ":" + ReadStrfromReg("RemoteRMSServerPort", "8023") + "/RMSServer"));
         //判断代理是否被创建,如果不成功,引发错误,否则调用服务方法
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
     if (svrobj == null)
     {
         //引发错误
         //Err.Raise(8000, "无法创建代理")
         return false;
     }
     //创建成功
     //MsgBox("建立代理成功")
     return true;
 }