Reputation: 1432
I have a dll I'm calling from another app. I need to store dll settings in separate xml file. So I'v created App.config file. It is looks like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="myKey" value="1"/>
</appSettings>
</configuration>
Than I try to get value from config with thic code:
var val=System.Configuration.ConfigurationSettings.AppSettings["myKey"];
But it always return null. Also key count of AppSettings equals zero, so there is no keys in it.
What's wrong with it? How can I store my settings in separate file?
Upvotes: 1
Views: 791
Reputation: 64933
If I'm not mistaken, you're looking for ConfigurationManager.OpenMappedExeConfiguration Method (ExeConfigurationFileMap, ConfigurationUserLevel).
You need to open that assembly configuration file as an another Configuration
object, and once you've got it, you'll be able to access those AppSettings
.
Upvotes: 2
Reputation: 51
Make sure the configuration mentioned in your question is in in config file of the calling application and not in the App.config of the DLL.
Upvotes: 1