I am trying to implement a plugin framework in C# where each plugin is loaded in its own AppDomain
. I am having issues where the it seems that the remoting layer between AppDomains
is garbage collecting my plugin instances. Each plugin inherits from this class:
public class PluginRefObject : MarshalByRefObject{
public override object InitializeLifetimeService() {
return null;
}
}
Which I thought would give the object an infinite lifetime. However, the plugins seem to work for a little bit and then suddenly I get a RemotingException
with an error message:
Object 'longhexstring.rem' has been disconnected or does not exist at the server
Which, from Googling, I believe means that the GC has deleted my remote object. Do I have to do something else to keep this object alive?