[RESOLVED] How to dynamically load and use a .NET dll
I have some dlls in my app folder. Each one contains 3 methods: methodA methodB methodC; of course the methods from one dll do stuff in different way that the others.
Since I want to be able to add new dlls and use it without rebuild the app, I would like to store the dlls name in a db table, when app start I check if dlls listed in db exist, and show in in the program that this feature are available; then when the program need a specific one, I would load the selected dll(by the string result got from db query), and execute the methods.
Can be done in vb.net?
I have some dlls in my app folder. Each one contains 3 methods: methodA methodB methodC; of course the methods from one dll do stuff in different way that the others.
Since I want to be able to add new dlls and use it without rebuild the app, I would like to store the dlls name in a db table, when app start I check if dlls listed in db exist, and show in in the program that this feature are available; then when the program need a specific one, I would load the selected dll(by the string result got from db query), and execute the methods.
Can be done in vb.net?
This can certainly be done - you would need to use reflection for this though. If you want to really get into this then you might have a lot of reading to do.... However I have attached a very simple console app that shows how you can do this.
The sample is made up of three projects.
The Shared project defines a basic interface, IDemo, that is required for all plugins to implement and is referenced by the other two projects.
The Plugin project is a simple console application that looks in a folder called "plugins" as a sub folder of the exe, finds any dlls and loads them, it loops through all the declared types, finds any that support the shared IDemo interface.
The Lib1 project is a very basic example of a plugin.
If you build the solution and copy the compiled Lib1.dll to a folder called "plugins" in the same folder as the pluin.exe you should be able to run the app and see what it does.