Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2007

Tip: Looking for answers? Try searching our database.

Settings for Windows Service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Demetri - 25 May 2007 16:13 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.