Reputation: 64173
I wrote a Windows Service program, say myService.exe and it has myService.exe.config file. But it seems changes to the app.config is not repected by the service until the service is restarted. So, is this by design? Or how could I make my service always respects the config file change without restarting?
Thanks!
Upvotes: 2
Views: 2261
Reputation: 51709
This is by design, it doesn't work the same as a web.config file.
You can use a FileSystemWatcher object to monitor for changes to the config file, and take an appropriate action if the file changes.
Upvotes: 3
Reputation: 754230
Yes, any .NET console/Winforms/Windows Service application will read its corresponding config file at startup and cache its contents. Altering it while the app is running typically doesn't change the running app.
If you need this kind of feature, you'd have to implement that yourself - e.g. make the app re-check the config periodically, or respond to a filesystem-watcher event that the file has changed.
Upvotes: 3