/// <summary> /// Publishes this object for remoting. /// </summary> /// <param name="objectUri">The remoting uri of the object.</param> /// <param name="createDefaultChannels"> /// Determinates if the default channels should be created or not. /// <seealso cref="RemotingConstants"/> /// </param> public void Start(string objectUri, bool createDefaultChannels) { if (createDefaultChannels) { // Register default channel for remote access Hashtable properties = new Hashtable(); properties["name"] = RemotingConstants.DefaultServiceChannelName; properties["port"] = RemotingConstants.DefaultServicePort; IChannel currentChannel = RemotingConstants.GetDefaultChannel(properties); ChannelServices.RegisterChannel(currentChannel, false); } WellKnownServiceTypeEntry serviceTypeEntry = new WellKnownServiceTypeEntry( GetType(), objectUri, WellKnownObjectMode.Singleton); RegisterService(InnerHandler); RemotingConfiguration.RegisterWellKnownServiceType(serviceTypeEntry); }
/// <summary> /// Connects to the server. /// <see cref="InterLinqQueryHandler"/> /// </summary> /// <seealso cref="ClientQueryHandler.Connect"/> public override void Connect() { if (queryRemoteHandler == null) { if (makeDefaultConnection) { Hashtable properties = new Hashtable(); properties["name"] = RemotingConstants.DefaultServiceChannelName; ChannelServices.RegisterChannel(RemotingConstants.GetDefaultChannel(properties), false); url = string.Format("{0}://{1}:{2}/{3}", RemotingConstants.DefaultServiceProtocol, RemotingConstants.DefaultServerName, RemotingConstants.DefaultServicePort, RemotingConstants.DefaultServerObjectName); } queryRemoteHandler = (IQueryRemoteHandler)Activator.GetObject(typeof(IQueryRemoteHandler), url); if (queryRemoteHandler == null) { throw new Exception("Connection to server could no be made."); } } }