How to read an assembly.dll.config
There is the common misconception that only a app.exe.config can be read in .NET C#. The truth is that the app.config is automatically read, while any other (correctly formed) app.config XML file can be read "manually".
To open a named config file:
- Reference System.Configuration.dll assembly
- Using System.Configuration
- Create code like:
Configuration GetDllConfiguration(Assembly targetAsm) {
var configFile = targetAsm.Location + ".config";
var map = new ExeConfigurationFileMap {
ExeConfigFilename = configFile
};
return ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
}
Sources:
Keywords: .NET, C#, app.config, dll.config, ConfigurationManager
Comments
Post a Comment