R – .NET: Channel and sinks between unrelated appdomains

appdomainnetremoting

I am of the understanding that when a new appdomain is created, the framework creates channels and sinks implicitly. If it didn't, you couldn't create an object in one appdomain and make use of a proxy in the other.

(This is an understanding; please correct me if I am wrong.)

Additionally, if an object is marshaled for remoting purposes, a channel must be explicitly registered in order for others to make use of it.

(Right so far?)

Here's where my understanding breaks down. Scenario:

Appdomain 1: Remoting server with a marshaled object, channel is registered.
Appdomain 2: Client wishing to make use of the marshaled object.
Appdomain 3: For a plugin. Created from within appdomain 1 (server), creating the aforementioned implicit channels between appdomains 1 and 3.

If an object is created in appdomain 3 (plugin) but the proxy reference is to be used in appdomain 2 (client), channel(s) and sinks are necessary. How do I do this?

Best Answer

The answer is to simply register a channel within appdomain 3 (plugin appdomain). I thought that there had to be more explicit plumbing between the two appdomains, but it seems that as long as each appdomain has a channel registered, the remoting infrastructure handles everything else.