Our application contains many modules which could be dynamically pushed to the our application after it is installed and running. All those modules might require some display at the UI. So I am thinking that we could build a UI exe which could load UI component from a DLL (or any other type of assembly). Let’s say module1 and module2 are active at the machine, we would display a “module1” and “module2” at the left frame of the UI. If user clicks on “module1”, the right frame would open the screen for module1 which is loaded from the another assembly (such as DLLs) which is pushed down together with module1.
Just wonder if this pluggable UI architecture is even possible at the Windows Form or not. I did some search on internet and I didn’t find any useful information around this.
Yes it is possible and I have done this my self.
The best way to do this is you create a 2nd DLL outside of the program. Inside that DLL you define a interface that your plugin will implement. You then make your form in the main EXE load all the DLL’s in a directory and see if it contains any classes that implement that interface. In your plugin DLL’s you also reference the same DLL and have your modules implement that interface. Any functions you want common to all of your Plugins you need to put in to
IMyPluginas that is the interface you will be casting everything to in your UI so only those functions will be visible.Note: This code was just copying and pasting a lot of my code, I don’t know if it will work perfectly as is, but this will get you close to where you need to go.