I am I am - 1 year ago 87
C# Question

How to access remote object from other computer in remoting

I have a server object as

TcpChannel tcp = new TcpChannel(1234);
ChannelServices.RegisterChannel(tcp, false);
string s = ConfigurationManager.AppSettings["remote"];
RemotingConfiguration.RegisterWellKnownServiceType(typeof(TestRemoting.InitialClass1), "TestRemoting", WellKnownObjectMode.Singleton);
Console.WriteLine("Server is running on 1234 channel...");
Console.WriteLine("Press Enter to Stop");

and I am accessing that object in mu client form like

InitialClass1 Icls = (InitialClass1)Activator.GetObject(typeof(InitialClass1), "tcp://localhost:1234//TestRemoting");

Now I am keeping my remote object in another computer. How can I access my server object from that computer. If I access the server object from my (local) computer, I will use


I am using localhost here, because my server object and my client is same. So If those two are different, How can I access the server object.
I tried with my another computer IP


that time I am getting an exception as

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Answer Source

The message means most of the time that the client cannot find the service. You can use the following steps to determine where the connection fails:

  1. Check if the service is running on the remote machine.
  2. Check if the port number is correct.
  3. Ping the remote machine from the client.
  4. Open a telnet session to the remote machine on the port number of service.

The step on which it fails gives an indication of why it is failing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download