void registerMe(String nick, String _port) { try { _nick = nick; int port = Int32.Parse(_port); TcpChannel channel = new TcpChannel(port); ChannelServices.RegisterChannel(channel, false); server = (ChatServer)Activator.GetObject( typeof(ChatServer), "tcp://localhost:8086/ChatServer" ); ChatClient obj = (ChatClient)Activator.GetObject( typeof(ChatClient), "tcp://localhost:8086/ChatClient"); //pass the object here, so we keep a reference that link us to the UI rmc = new RemoteChatClient(this); String clientServiceName = "ChatClient"; RemotingServices.Marshal( rmc, clientServiceName, typeof(RemoteChatClient) ); if (server != null) { server.register(nick, "tcp://localhost:" + port + "/" + clientServiceName); isConnected = true; } } catch (SocketException) { System.Windows.Forms.MessageBox.Show("Could not locate server"); } catch (FormatException e) { System.Windows.Forms.MessageBox.Show("Invalid format port"); } catch (RemotingException e) { System.Console.WriteLine(e); } }