By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,277 Members | 1,433 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,277 IT Pros & Developers. It's quick & easy.

Configuration of Windows service

P: n/a
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.thi s[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.CurrentDirector y,
"MyService.exe.config");
// Map to the application configuration file.
ExeConfigurationFileMap configFile = new
ExeConfigurationFileMap();
configFile.ExeConfigFilename = exePath;
Configuration configServ =
ConfigurationManager.OpenMappedExeConfiguration(co nfigFile,
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

Mar 5 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
See here:

http://www.eggheadcafe.com/forumpost...umpostid=85647

This is an alternate method to pull info from (~any) config file.


"Olegus" <ol*********@gmail.comwrote in message
news:11**********************@64g2000cwx.googlegro ups.com...
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.thi s[System.Configuration.Configu
rationProperty]'
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.CurrentDirector y,
"MyService.exe.config");
// Map to the application configuration file.
ExeConfigurationFileMap configFile = new
ExeConfigurationFileMap();
configFile.ExeConfigFilename = exePath;
Configuration configServ =
ConfigurationManager.OpenMappedExeConfiguration(co nfigFile,
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

Mar 5 '07 #2

P: n/a
Thanks for your answer, Sloan.

I changed OpenMappedExeConfiguration to OpenExeConfiguration and it
works now. But I have a strong feeling that I use
OpenExeConfiguration before and it did not work. Hmmmm. Weird.
On Mar 5, 4:49 pm, "sloan" <s...@ipass.netwrote:
See here:

http://www.eggheadcafe.com/forumpost...umpostid=85647

This is an alternate method to pull info from (~any) config file.

"Olegus" <oleg.gus...@gmail.comwrote in message

news:11**********************@64g2000cwx.googlegro ups.com...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.thi s[System.Configuration.Configu
rationProperty]'
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.CurrentDirector y,
"MyService.exe.config");
// Map to the application configuration file.
ExeConfigurationFileMap configFile = new
ExeConfigurationFileMap();
configFile.ExeConfigFilename = exePath;
Configuration configServ =
ConfigurationManager.OpenMappedExeConfiguration(co nfigFile,
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

Mar 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.