public static bool ConnectionServer(ChannelModel model) { //获取远程对象 var channelGroup = model.ChannelGroupType == "1" ? ChannelGroup.TCP : ChannelGroup.HTTP; string protocol = "tcp"; if (channelGroup == ChannelGroup.HTTP) { protocol = "http"; } string uri = GetServerUrl(protocol, model); try { ChannelClass.StartChannel(channelGroup, model.ChannelName); _iHiCoordinator = Activator.GetObject(typeof(IHiCoordinator), uri) as IHiCoordinator; _wrapper = new EventWrapper(); _wrapper.Server2ClientEvent += GetServerMessage; if (_iHiCoordinator != null) { _iHiCoordinator.Server2ClientEvent += _wrapper.OnServer2ClientEvent; } ChannelDetail = model; string clientName = ChannelClass.GetMyHostName(); if (_iHiCoordinator != null) { _iHiCoordinator.IClient2Server(clientName + "成功连接服务"); } return(true); } catch (Exception ex) { MsgBox.ShowInformation("启动服务失败:" + ex.Message + "\n\n" + uri); return(false); } }