I have a requirement to create a windows service application that will need
have settings (e.g. list values, connection settings, etc.) stored externally
(i.e. not hard coded).
To allow administrators to manage the settings I'll be creating a windows
form application, very simple one, that will run in the system tray and when
a setting needs to change (once in a blue moon) the administrator can right
click and change/add a setting through a dialog window. The dialog will give
the user the ability to restart the service so the settings can be read by
the service at start up again.
Here is my question. To store the settings i'm inclined to add an app.config
to the windows service and have the windows form app read/save settings to
the config file. What is the most appropriate and proper way to handle
something like this?

Signature
-Demetri
Bryan Phillips - 27 May 2007 04:56 GMT
Your approach is the most appropriate and simplest way of handling the
settings.
--
Bryan Phillips
MCT, MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
Web Site: http://www.composablesystems.net
> I have a requirement to create a windows service application that will need
> have settings (e.g. list values, connection settings, etc.) stored externally
[quoted text clipped - 14 lines]
> --
> -Demetri
Yeliz - 04 Jun 2007 07:34 GMT
Demetr, you can use OpenMappedExeConfiguration to get the configuration file you want to modify.
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = path;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
config.AppSettings.Settings["Server"].Value = ".";
config.Save(ConfigurationSaveMode.Modified);
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Yeliz - 04 Jun 2007 07:35 GMT
Demetr, you can use OpenMappedExeConfiguration to get the configuration file you want to modify.
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = path;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
config.AppSettings.Settings["Server"].Value = ".";
config.Save(ConfigurationSaveMode.Modified);
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com