Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using a App.Config file within a windows service to store the configuration setting for windows service, I need to do recompile the windows service in order to get the new settings to be in effect in the windows service if I make changes to the app.config file.
Even I'm not able to get the values which I have mentioned in the app.config file.
How to use effectively app.config in windows service and how to read.
I'm using VS2008.


Thanks in advance.
Posted

You can make use of custom configuration sections and then read it using ConfigurationManager class.

You do not need to recompile anything if you change only the values in the custom configuration properties. If you change the section structure itself, you need to re-deploy.

Also, you will need to restart the service to read the new values.

Update: It is same as you would do for the windows form. Check out MSDN for custom configuration section example. It is there.
 
Share this answer
 
v2
Comments
YSridhar 31-Aug-10 7:49am    
Can u provide any sample code or steps for, how to use config file in windows service.
You could just watch for changes to the config file with a FileSystemWEatcher object, and then re-read the file when a change has been detected.

You can write a simple console application to make it easier to debug, and then move the debugged code into your windows service.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900