Using configuration files in DLL is not trivial.
To accomplish this, we must follow these steps:
- Add a reference to System.Configuration
- Add a new Application Configuration File and the name it [Your project].dll.config
- Change the BuildAction property of the config file to Content
- Change the Copy to Output property to "Copy Always"
After these steps, you can access the configuration file this way:
Configuration myDllConfig =
AppSettingsSection myDllConfigAppSettings =
Your configuration file should look like this:
<add key ="MyAppSettingsKey" value="MyValue"/>
That's all. Hope you enjoy this tip.
I'm a system analyst (senior) and I live in Belo Horizonte, Minas Gerais, Brazil. I've been working with software development since 1996.