tags:

views:

122

answers:

1

I have a client/server application that must use .NET Remoting (not WCF because the project is using Framework 2).

The following code (copied heavily from MSDN) works:

                _clientChannel = new IpcClientChannel();

                ChannelServices.RegisterChannel(_clientChannel, false);

                IMyObject myObject= (IMyObject)
                        Activator.GetObject(typeof(IMyObject),
                        "ipc://MyServer/Address");

                if ( myObject.Equals(null) )
                    Console.WriteLine("Error: unable to locate server.");
                else
                    returnString = myObject.SomeMethod();

                ChannelServices.UnregisterChannel(_clientChannel);

But what do these three lines do?

                    _clientChannel = new IpcClientChannel();

                    ChannelServices.RegisterChannel(_clientChannel, false);

                    ...

                    ChannelServices.UnregisterChannel(_clientChannel);

_clientChannel doesn't get used anywhere afterwards in the working code. The working code also seems to work without those three lines. Can I get rid of them without losing functionality?

+1  A: 

The channel is used for the communication. The Object you get through the Activator is only a proxy objects that hides the real implementation and uses the channel for communication.

See MSDN for further information on remoting

crauscher