Background
I developed a custom plugin architecture using a derivation of the Observer/Event Pattern and bits and pieces of code from the following:
Code Project: Plugin Manager
Microsoft: AppDomains
Daniel Soltyka: Simple Plugin
I had an issue in the past. Each plugin is loaded in it's own app domain so that they cannot see each other nor can they see things in the main app domain (we have proprietary data in our application we do not want plugin developers to see). A proxy is created with each new app domain/plugin in order to communicate with the plugin from the main app. The issue was that the proxy became disconnected after 5 minutes or so. This was easily solved by overriding the InitializeLifetimeService()
method and returning null (reference).
The Problem
The issue now is on the other side of things. I am "registering" callback functions on the plugin side by sending delegates from the main app side to each plugin. The plugins can then call these delegates which will call the functions in the main app. The delegates, though, apparently get disconnected just like the proxies in the above explanation.
I read this on SO and the ClientSponsor.Register()
method sounds great, but it needs a "MarshalByRefObject" as parameter. Mine are delegates, so no dice.
I want to find a way to keep my main app delegates connected across app domains the way the plugin proxies are.
Any ideas?