.NET2.0 Remoting - Why is ClientChannel registration required?

I have a client / server application that needs to use .NET Remoting (not WCF because the project uses Framework 2).

The following code works (copied from MSDN):

                _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 are these three lines doing?

                    _clientChannel = new IpcClientChannel();

                    ChannelServices.RegisterChannel(_clientChannel, false);

                    ...

                    ChannelServices.UnregisterChannel(_clientChannel);

      

_clientChannel is not used anywhere in production code. Working code also works without those three lines. Can I get rid of them without losing functionality?

0


source to share


1 answer


The channel is used for communication. The object you get through the Activator is just proxy objects that hide the real implementation and use the channel to communicate.



See MSDN for more information on removing

+1


source







All Articles