Reputation: 2045
I am trying to read values from the different configSections
of App.Config
file from a different application using this code:
public string ReadValue(string FileName,string Key)
{
//File name is the path of the App.Config from a different application
ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
configMap.ExeConfigFilename = FileName;
Configuration config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
var section =config.GetSection("dev") as AppSettingsSection ;
return section[Key];
}
I am getting error as System.Configuration.ConfigurationElement.this[System.Configuration.ConfigurationProperty]' is inaccessible due to its protection level
How do I get this code working? Thanks
Upvotes: 0
Views: 855
Reputation: 5832
Try this:
Upvotes: 1