Friday, June 5, 2009

Using IpcClientChannel to communicate with a process that might go away

IpcChannel is the managed class that provides access to named pipes. It's another remoting channel (alongside TcpChannel and HttpChannel).

If the client is accessing a Singleton it typically registers that type with the remoting infrastructure (via RemotingServices.RegisterWellKnownClientType()) then uses new to construct thet object. Since the type has been registered, behind the scenes everything is taken care of to access this object remotely.

What happens if you're talking to a process that you may need to periodically restart? Unfortunately you can't UnregisterWellKnownClientType() and you get an exception if you try to register the same type again (e.g., at a different URL).

Fortunately you can manually access the remote object with Activator.GetObject().

No comments :

Post a Comment