private void button1_Click(object sender, EventArgs e) { int port = int.Parse(textBox1.Text); TcpChannel channel = new TcpChannel(port); ChannelServices.RegisterChannel(channel, false); RemoteClient rc = new RemoteClient(); RemotingServices.Marshal(rc, "ChatClient", typeof(RemoteClient)); server = (ServerInterface)Activator.GetObject( typeof(ServerInterface), "tcp://localhost:8086/ChatServer"); try { server.Connect(port); } catch (SocketException) { System.Console.WriteLine("Could not locate server"); } }