/// <summary> /// Returns a running instance of CacheServer; does not start the service. /// If user specifies in the client application an ip address to server channels to bind to /// then this method creates the server channel bound to that ip. also the object uri then uses /// the ip address instead of server name. /// </summary> /// <returns></returns> public override ICacheServer ConnectCacheServer() { string objectUri = ""; string protocol; string ip = ""; try { if (_channel == null) { _channel = new RemotingChannels(); ip = ServiceConfiguration.BindToIP.ToString(); if (ip != null && ip.Length > 0) { if (_useTcp) { _channel.RegisterTcpChannels("NCC", ip, 0); } else { _channel.RegisterHttpChannels("NCC", ip, 0); } } else { if (_useTcp) { _channel.RegisterTcpChannels("NCC", 0); } else { _channel.RegisterHttpChannels("NCC", 0); } } } protocol = _useTcp ? @"tcp://" : @"http://"; if (ip != null && ip.Length > 0) { objectUri = protocol + ip + ":" + _port + @"/" + CacheHost.ApplicationName + @"/" + Alachisoft.NCache.Management.CacheServer.ObjectUri; } else { objectUri = protocol + _serverName + ":" + _port + @"/" + CacheHost.ApplicationName + @"/" + Alachisoft.NCache.Management.CacheServer.ObjectUri; } CacheServer server = (CacheServer) Activator.GetObject(typeof(CacheServer), objectUri, WellKnownObjectMode.Singleton); int ccount = server.Caches.Count; if (ccount > 0) { server = server; } return(server); } catch (SocketException socketException) { throw; } catch (ManagementException mexp) { throw; } catch (Exception e) { throw new ManagementException(e.Message, e); } }