We are building a .NET application where we load external code assemblies ("plugins"). Up to this point, we were loading these assemblies into a single (main) application domain.
We would like to be able to unload an assembly after it has been loaded.
To this end, we are designing a system that will create a separate secondary AppDomain to host the plugin assemblies, to be unloaded at will.
The problems we have with this approach:
- The plugin DLL will need to interact with classes in the main AppDomain (logger, for example).
- The data that is sent to the plugin dll is not necessarily marked as Serializable or derived from MarshalByRefObj.
Is there any common practice of partitioning the application in such cases? What is the best solution we could go for ?
Another interesting question -- why doesn't MarshalByRef goes by an attribute and forces us to derive from an object?