Reputation: 35
I have a "frontend" form application.
In my application the user can chooses external dll assemblies from different directoryes:
plugins_repository_directory
|
| first_item_directory
| Plugin.dll
| ...
|
| second_item_directory
| Plugin.dll
| ...
|
| last_item_directory
| Plugin.dll
All the external assemblies have the same namespace and some common features:
Every "Plugin" have a UserControl.EntryPointView class and a static PluginInfos class.
Ok
When the user choose a plugin from file-system i do the following:
public void LoadPlugin(string fileName){
myPlugin= Assembly.LoadFile(fileName) //remember to use LoadFile instead of Load
Type entryPointViewType= myPlugin.GetType("Plugin.EntryPointView");
UserControl myPluginView (UserControl)Activator.CreateInstance(entryPointViewType);
myFrontendPanel.Controls.add(myPluginView);
((IEntryPointView)myPluginView).initialize(Stuff somestuff);
//and so on...
}
Now the user can work on his plugin loaded inside the front-end panel.. very good
After a while the user want to load a different plugin, so he chooses a different dll file and basically I dispose the old EntryPointView instance and I run LoadPlugin() again.
I think you are understanding what I am trying to achieve: Various plugins assemblies have the same name/namespace because I want to quick build new plugins via copy-past plugin project -> add/remove/change functionalities -> build as dll -> et voilà
Now it seems legit to me but i am not very experienced architect so I want to ask some question:
thank you in advance
Upvotes: 1
Views: 812