private void button1_Click(object sender, EventArgs e) { String _clientPort = textBox2.Text; //CLIENT->SERVER TcpChannel channel = new TcpChannel(); ChannelServices.RegisterChannel(channel, true); obj = (IServer)Activator.GetObject( typeof(IServer), "tcp://localhost:8086/ChatServer"); //CLIENT<-SERVER IDictionary RemoteChannelProperties = new Hashtable(); RemoteChannelProperties["port"] = _clientPort; RemoteChannelProperties["name"] = "tcp" + _clientPort; TcpChannel chan = new TcpChannel(RemoteChannelProperties, null, null); ChannelServices.RegisterChannel(chan, true); ChatClientRemote client = new ChatClientRemote(this); RemotingServices.Marshal(client, "ChatClient", typeof(ChatClientRemote)); obj.registar(_clientPort); }