|
|
|
start date: Thu, 16 Aug 2007 17:58:53 -0700,
posted on: microsoft.public.dotnet.framework
back
| Thread Index |
|
1
Paul am
|
|
2
GlennDoten
|
Refresh application settings at runtime
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
Date:Thu, 16 Aug 2007 17:58:53 -0700
Author:
|
Re: Refresh application settings at runtime
Paul wrote:
> Sorry, left out some info:
>
> I'm using my.settings in framework 2.
>
> "Paul" wrote:
>
>> 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
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?
--
-glenn-
Date:Fri, 17 Aug 2007 07:28:28 -0400
Author:
|
|
|