views:

42

answers:

1

I'm using .Net remoting to set up a bidirectional communication line between two objects. The basic structure is as follows:

Instances of RemoteObjectA call methods on StaticObjectA.
Instances of RemoteObjectB call methods on StaticObjectB.
StaticObjectA needs to be able to call methods provided by RemoteObjectB.
StaticObjectB needs to be able to call methods provided by RemoteObjectA.

The problem with this setup is the circular reference in RemoteObjectA gets StaticObjectA gets RemoteObjectB gets StaticObjectB gets RemoteObjectA...

I implemented an interface IRemoteObjectA and IRemoteObjectB and had the remote objects inheret from their respective interfaces, but then setting up the remoting fails.

If the solution to this problem is: "don't use remoting", I can deal with that. Just wanted to make sure I wasn't missing a simple solution.

A: 

Figured it out.

The trick was to create an interface for the static objects. So StaticObjectA and RemoteObjectA both get IStaticObjectA and StaticObjectB and RemoteObjectB both get IStaticObjectB. This way StaticObjectA can get RemoteObjectB and StaticObjectB can get RemoteObjectA with no circular dependency.

mphair