我正在尝试使用以下代码从其他应用程序中读取configSections
App.Config
个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];
}
文件中的值:
System.Configuration.ConfigurationElement.this[System.Configuration.ConfigurationProperty]' is inaccessible due to its protection level
我收到错误limit
如何使此代码正常工作? 感谢