Do you have to restart a windows service if you change the app.config?
No, you don't have to. But if you want for changes in app.config
to take effect, you might need to restart it. Or you might want to implement a custom configuration file watcher mechanism which would alter services' settings on the fly.
This goes way out of the scope of the question, but I would guess you want to make changes only in some "application-specific" section (appSettings, etc.).
You are better off writing your own config section handler, which monitors it's own config file - the approach nlog uses. Check the section "Automatic reconfiguration".
Usually yes. However you could write a windows service that would put a file monitor on the configuration file and sense a modification and apply it without the need to restart.
For example the Log4Net logging framework offers such a mechanism for its configuration file.
I've used this before. Essentially this reloads the specified section before retrieving the value. Quite possibly less efficient than a config file watcher that refreshes on demand, but certainly effective used carefully.
ConfigurationManager.RefreshSection("appSettings")
sValue = ConfigurationManager.AppSettings(name)
ConfigurationManager.RefreshSection("appSettings") sValue = ConfigurationManager.AppSettings(name)
very good
thanks