Problem with configuration reading
-
I have a problem with configuration files (Windows Forms application). I'm developing an application, that is supposed to be using plug-ins. Plug-ins are enclosed into a dll, that is put into 'plugins' subdirectory in the application root. Each plug-in can have it's own setting, so to make it comfortable to use I want to have configuration of each plug-in in separate config file (for example when plugin1.dll needs some settings it is stored in the plugin1.dll.config). I wanted to access configuration through the config section (I don't like the "settings" section and it doesn't work for some of my scenarios). I have now class
Plugins.Plugin1.Settings
that derives fromConfigurationSection
and a section in the app.config that points to this type. I point this type with fully qualified name (I mean with assembly name: 'Plugins.Plugin1.Settings, Plugins.Plugin1'). Everything seems fine. I copy Plugins.Plugin1.dll and Plugins.Plugin1.dll.config to 'plugins' directory and run the application. When I try to access settings I get exception saying, that there was an error creating configuration section module, because assembly Plugins.Plugin1 or one of it's dependencies could not be loaded. Stupid thing about this (for me) is that the code, where exception is thrown from inside the Plugins.Plugin1 code. I suppose the problem is that Plugins.Plugin1.dll isn't located inside 'bin', but inside subdirectory, but I can't throw it to bin, cause it isn't part of the main code, it's just an extension. How can I load data from this configuration file? Searched the web all day and didn't find anything usable... maybe I was asking Google the wrong questions ;-)Don't forget to rate answer, that helped you. It will allow other people find their answers faster.