DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
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:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us