As per my title, I would like to clarify: Is it advisable to update the config file while a .Net windows service is running?
What would be its implications, if this is possible?
There are other excellent answers here, but what are you asking? Are you asking about a service that <strong>you</strong> are writing? Or about someone else's Service.
If it is about a service you are going to write, then no, there is no automatic reload of the .config file when it is changed. You will either have to:<ol><li>Restart the service to see the changes.</li> <li>Write your service to use a FileSystemWatcher to see if the config file has been changed and then decide what you want to do with any or all the values that have changed.</li> </ol>
If it is about someone else's service, you will need to ask them how it works based upon the above description.Answer2:
This should have no effect on the running program. Configuration is loaded during application startup. If you want those new settings to take effect, you need to restart the service.
<strong>Edit</strong>: More to the point of answering your question: When one creates a Windows service in .NET (I'm using Visual Studio 2010), an application configuration file is not created with it by default. By adding a New Item / Application Configuration File (App.config), you are creating a file that gets loaded at the start of the service. As commented below, there is no guarantee that it isn't being monitored during run time (unless you're the creator and you know that's the case), but this is not the common practice for App.config.
Under these standard conditions, it is advisable to make the changes, while running, after backing up the working copy of the config file. Then restart the service. If you broke it, revert back to your working copy.Answer3:
You can do it but it comes with a cost, do you want your service poll to know if there is any changes to the config file while it is running ? Generally, I would not recommend polling for the content changes in the config file.