Plugins and Assembly References
-
Hello. I am designing an application that will make use of plugins (.net assemblies loaded at runtime containing classes implemented from a common interface). The issue is, i would like to be able to put these DLLs in a folder other than the application's folder, so it could be in a folder like \Plugins\ or something. It works fine sometimes, the problem is that when a plugin references a local assembly, it tries to find it in the application's folder and not the plugin's folder. For instance, if one of the plugins is loading XLS files and I have an XLS file reader class in a seperate assembly along with the plugin, I will get an error since the application is trying to load the assembly from its location and not the plugin's location. Is there any way to get around this without dumping my assemblies in the GAC?
-- Steven Hunt
-
Hello. I am designing an application that will make use of plugins (.net assemblies loaded at runtime containing classes implemented from a common interface). The issue is, i would like to be able to put these DLLs in a folder other than the application's folder, so it could be in a folder like \Plugins\ or something. It works fine sometimes, the problem is that when a plugin references a local assembly, it tries to find it in the application's folder and not the plugin's folder. For instance, if one of the plugins is loading XLS files and I have an XLS file reader class in a seperate assembly along with the plugin, I will get an error since the application is trying to load the assembly from its location and not the plugin's location. Is there any way to get around this without dumping my assemblies in the GAC?
-- Steven Hunt
Hi Steven, I'm assuming that the Plugins folder is a subdirectory of the executable's folder. In that case, you should be able to use the Probing element in the app.config file to have the runtime look for assemblies in that folder. Also, you can read up on the whole process: How the Runtime Locates Assemblies Hope that helps, Eugene
-
Hi Steven, I'm assuming that the Plugins folder is a subdirectory of the executable's folder. In that case, you should be able to use the Probing element in the app.config file to have the runtime look for assemblies in that folder. Also, you can read up on the whole process: How the Runtime Locates Assemblies Hope that helps, Eugene
Thanks for the help. I also discovered Assembly.LoadFrom(string location), which also looks promising.
-- Steven Hunt