Here's the story of my question:
I have a .Net (C#) windows application. This app contains a Panel, a Drop Down and a button.
There's a folder named plugins
near my executable file (winapp...exe) which i wish it contains my custom program module files. Like (add2digit.moduleextention, add3digit.moduleextention, addNdigit.moduleextention, ...).List of these files will be shown in m开发者_运维技巧y drop down. All these custom module files need to be written in C#, and all have to implement an interface contains one methods { panel:: GetGUI() };
When i change the drop down, i wish to load the selected module GUI into the panel using it's GetUI() method. By this manner i wont need to recompile my code if i developed further modules. Please give me some keywords or solutions which help me figure this problem out.
You'll need to create an Interface
with GetUI()
and other methods declared in it and implement that in plugins, then in your main application you should do something like this:
using System.Reflection;
// ...
Assembly assembly = Assembly.LoadFile(file);
yourInterface plugin = (yourInterface)Activator.CreateInstance(Type.GetType(assembly));
// ...
plugin.GetUI(); // or whatever
精彩评论