469,645 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Configuration of Windows service

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
2 13946
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
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.

Similar topics

4 posts views Thread by PeterW | last post: by
1 post views Thread by noah.blumenthal | last post: by
1 post views Thread by Karch | last post: by
reply views Thread by =?Utf-8?B?QWRyaWFuIENvbGU=?= | last post: by
5 posts views Thread by dm3281 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.