0

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?

4

1 回答 1

1

该通道用于通信。你通过 Activator 得到的 Object 只是一个代理对象,它隐藏了真正的实现,使用通道进行通信。

有关远程处理的更多信息,请参阅MSDN

于 2009-05-27T19:55:20.140 回答