C# – Passing remote object from one App Domain across to another process


Basically I have 2 app domains in my first process (a service) this talks to another process (exe) that runs on the desktop using IPC remoting. In the second app domain of my service I load my plug ins and then interact with them them using an interface from the default app domain. This allows me to unload the plugins whenever I want by unloading the second app domain.

This works fine within the service process but the problem I have found is when I want to pass one of the plugin objects (so a proxy) across to the other process and run it within the processes app domain. If I pass it in currently it gives me the following remoting exception:

"This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server"

Is there any way to achieve what I am after, which I suppose is passing on a remote object? This is rather a difficult situation to describe, so please ask for clarification if it will help. Any suggestions would be greatly appreciated.

Best Solution

I have seen this error message in a similar situation to yours when I was doing the following:

In the Service process, I had 2 app domains: A and B.

It is in AppDomain B that I setup the remoting channel, and created a remote object, RemotableObject, to the remote Process.

Then, I created an object, anObject, in AppDomain A, and called:


Now somewhere in the remote process, I am accessing a property of anObject (anObject.Name) and this is where the error occurs!

I believe this happens because .NET is trying to access the original object that you created in AppDomain A with the data that you are requesting, but, because there is no remoting channel to AppDomain A, the remoting channel was established between appdomain B and the remote process, the data cannot be grabbed.

To resolve this issue in my case, I created a factory in AppDomain B that would create the object that I wanted and passed a reference back to AppDomain A (anObject needs to inherit from MarshalByObjectRef anyway if you are passing across remoting) and it seems to have worked.

Related Question