Olegus
2007-03-05 20:13:25 UTC
I have Windows service MyService, that reads some settings from
MyService.exe.config file via
ConfigurationManager.AppSettings["Setting_Key_Name"]. I tried to write
small WinForm frontend app(called it Manager.exe) to manage settings
of MyService, but have problems with accessing MyService.exe.config
from Manager app. I am getting this error:
"System.Configuration.ConfigurationElement.this[System.Configuration.ConfigurationProperty]'
is inaccessible due to its protection level"
My Manager app has this code to open a service config and read values
from it:
// Open service configuration file
string exePath =
System.IO.Path.Combine(Environment.CurrentDirectory,
"MyService.exe.config");
// Map to the application configuration file.
ExeConfigurationFileMap configFile = new
ExeConfigurationFileMap();
configFile.ExeConfigFilename = exePath;
Configuration configServ =
ConfigurationManager.OpenMappedExeConfiguration(configFile,
ConfigurationUserLevel.None);
string value = configServ.AppSettings["CheckUpdateTimeout"];
I can read/write from/to Manager.exe.config but looks like it is
prohibited in .NET to work with another app's config files.
Is there a solution to my problem?
Thanks,
Olegus
MyService.exe.config file via
ConfigurationManager.AppSettings["Setting_Key_Name"]. I tried to write
small WinForm frontend app(called it Manager.exe) to manage settings
of MyService, but have problems with accessing MyService.exe.config
from Manager app. I am getting this error:
"System.Configuration.ConfigurationElement.this[System.Configuration.ConfigurationProperty]'
is inaccessible due to its protection level"
My Manager app has this code to open a service config and read values
from it:
// Open service configuration file
string exePath =
System.IO.Path.Combine(Environment.CurrentDirectory,
"MyService.exe.config");
// Map to the application configuration file.
ExeConfigurationFileMap configFile = new
ExeConfigurationFileMap();
configFile.ExeConfigFilename = exePath;
Configuration configServ =
ConfigurationManager.OpenMappedExeConfiguration(configFile,
ConfigurationUserLevel.None);
string value = configServ.AppSettings["CheckUpdateTimeout"];
I can read/write from/to Manager.exe.config but looks like it is
prohibited in .NET to work with another app's config files.
Is there a solution to my problem?
Thanks,
Olegus