G
Guest
I am designing a plugin system for a window application using .NET(C#
specifically). One of the requirements of the plugin system is to be able to
dynamically load/unload plugins.
My initial thought was to use System.Reflection.Assembly.Load to load the
plugins dynamically. This worked great, but I was left with no way to
dynamically unload the plugin.
So now I come to creating a new AppDomain for the plugins to reside in,
since the AppDomain can be unloaded. The problem I see with this is that
when I dynamically unload one plugin, the rest will have to be reloaded and
any data will be lost. Is that true? I could notify the plugin when it is
going to be unloaded and it could persist itself, or I could persist each
plugin automatically I suppose.
So I thought I could have an AppDomain for each plugin. Is this feasible?
Would this take up too many resources? Also in this case I would have to
have one instance of the assembly loader for each plugin since the assembly
should be loaded from inside the current application domain.
I guess I am just looking for some opinions as to which approach is the
best, easiest or hopefully both!
Thanks for your help!
specifically). One of the requirements of the plugin system is to be able to
dynamically load/unload plugins.
My initial thought was to use System.Reflection.Assembly.Load to load the
plugins dynamically. This worked great, but I was left with no way to
dynamically unload the plugin.
So now I come to creating a new AppDomain for the plugins to reside in,
since the AppDomain can be unloaded. The problem I see with this is that
when I dynamically unload one plugin, the rest will have to be reloaded and
any data will be lost. Is that true? I could notify the plugin when it is
going to be unloaded and it could persist itself, or I could persist each
plugin automatically I suppose.
So I thought I could have an AppDomain for each plugin. Is this feasible?
Would this take up too many resources? Also in this case I would have to
have one instance of the assembly loader for each plugin since the assembly
should be loaded from inside the current application domain.
I guess I am just looking for some opinions as to which approach is the
best, easiest or hopefully both!
Thanks for your help!