PC Review


Reply
Thread Tools Rate Thread

Re: app.config & FileSystemWatcher

 
 
sloan
Guest
Posts: n/a
 
      9th Jul 2008
You might find some useful hints here:

http://www.eggheadcafe.com/articles/20041204.asp
// nasty bug in FileSystemWatcher fires twice (in about 4 ms) on changed
file. This is a workaround...



I'm not sure if it will help you, but sometimes its nice to see what someone
else tried.





"Jeff Mason" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to write some code that will detect changes in a Windows
> Service app's
> .config file and reflect the modified appSetting entry in my code.
>
> We have a windows Service we've written and every once in a while we need
> to modify a
> setting in its .config file. Right now we restart the service whenever
> the config
> entry changes.
>
> We'd like to have the .config update be recognized automatically.
>
> It's easy enough to hang a FileSystemWatcher off the application's .config
> file to
> detect a change. In the event handler I am executing:
>
> ConfigurationManager.RefreshSection("appSettings")
>
> but this seems to have no effect. The value returned by subsequently
> referencing
> ConfigurationManager.AppSettings(<somekey>) is the original value, not the
> one just
> changed.
>
> The help for RefreshSection claims: "Refreshes the named section so the
> next time it
> is retrieved it will be re-read from disk." but this doesn't appear to
> work.
>
> What am I doing wrong?
>
> Thanks for any help.
>
> - Jeff
>
> -- Jeff



 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      11th Jul 2008
Good to know. Thanks for the followup.


"Jeff Mason" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Wed, 9 Jul 2008 13:31:59 -0400, "sloan" <(E-Mail Removed)> wrote:
>
>>You might find some useful hints here:
>>
>>http://www.eggheadcafe.com/articles/20041204.asp

>
> Thank you.
>
> I think I have a handle on what may be going on. The problem I'm having
> may be
> related to my running/debugging within the VS2005 environment. There are
> these
> <app>.vshost.* files that may be getting in the way. It sort of looks
> like the
> caching of config data is from the <app>.vshost.exe.config file and not
> the
> <app>.exe.config as it normally is in a "stand-alone" mode.
>
> I found that running my tests in a stand-alone environment works as I
> expected.
> Running inside VS2005 will work if I edit the <app>.vshost.exe.config and
> watch for
> changes on that file.
>
> Go figure.
>
> -- Jeff



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: app.config & FileSystemWatcher Jeff Winn Microsoft Dot NET Framework 0 5th Jul 2008 04:26 PM
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner Microsoft ASP .NET 0 9th Apr 2007 11:00 PM
DTDs for machine.config, web.config, security.config available ? =?Utf-8?B?UGF1bCBLZW5uZWR5?= Microsoft Dot NET Framework 1 5th Feb 2007 06:42 AM
How to config the web.config for both Internal and External users using Windows and Forms Authentication? ABC Microsoft ASP .NET 1 24th Oct 2005 03:37 PM
Configuration Error - c:\winnt\microsoft.net\framework\v1.1.4322\Config\machine.config Ivan Microsoft ASP .NET 1 21st May 2004 06:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:12 AM.