/// <summary> /// Registers the provided service to the DIPS port. /// </summary> /// <param name="service">The <see cref="IDIPS"/> to register /// to a particular port.</param> public static void Register(IDIPS service) { TcpChannel channel = new TcpChannel(Port); channel.StartListening(null); ChannelServices.RegisterChannel(channel, true); WellKnownServiceTypeEntry obj = new WellKnownServiceTypeEntry( typeof(IDIPS), "DIPS/Service", WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType(obj); }
private void btnListen_Click(object sender, EventArgs e) { if (_serverChannel == null) { //Registering the tcp channel _serverChannel = new TcpChannel(_port); ChannelServices.RegisterChannel(_serverChannel, true); //Registering the server component as a server activated object (SOA) RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteCalculator), "RemoteCalculator", WellKnownObjectMode.Singleton); _serverChannel.StartListening(null); btnListen.Text = "Stop Listening"; } else { btnListen.Text = "Start Listening"; //Unregistering the tcp channel so that server will not be available here after ChannelServices.UnregisterChannel(_serverChannel); _serverChannel = null; } }