Refresh application settings at runtime

G

Guest

Hi,

Help would be appreciated!

I am writing windows services that I do not want to restart unnecessarily.
Problem is that if I want to change application settings in the .config file,
say for instance a polling frequency, I have to restart the service to read
the new settings. All the methods to refresh/reread settings seem to work
only for user settings, not application settings.

How can I force my app to re-read the application settings from the .config
file after I've changed it at runtime?

Thanks!
Paul
 
G

GlennDoten

Paul said:
Sorry, left out some info:

I'm using my.settings in framework 2.

I suppose it is because the application settings cannot be
programatically written to like the user settings (at least not with the
code supplied by the classes in System.Configuration).

The ApplicationSettingsBase class provides these events:

- PropertyChanged
- SettingsChanging
- SettingsLoaded
- SettingsSaving

but my guess is they only notify you of events related to user settings
(I haven't checked).

It seems to me that the distinction between application and user
settings is that if you want to be able to change a setting at run-time
you must make it user scoped; if you want the setting to stay the same
for the life of the running application then you would make it an
application setting. Presumably this is why the application settings are
read-only and the user settings are read/write.

In the case of a web service, since you are the "user" in the sense that
you are the one that needs to customize the settings on behalf of the
consumers of the web service, why not make the settings you are
interested in changing at run-time into user scoped settings instead of
application scoped?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top