/egilh

Learning by doing

FileSystemWatcher does not work with DFS on Win2k3

Posted on Monday, May 08, 2006 9:18 PM

The ASP.NET cache can be used from any .NET program, but for several reasons I had to make my own caching system of a configuration file. In theory it works; my cached object will automatically be removed when the file has been changes. There are multiple worker processes and each of them use a FileSystemWatcher to notice if there are any changes to the configuration file:

private static System.IO.FileSystemWatcher _watcher = null;
...
_watcher = new System.IO.FileSystemWatcher(HttpContext.Current.Server.MapPath("."), MY_CONFIG_FILE);                       
_watcher.Changed += new FileSystemEventHandler(callbackConfigChanged);
_watcher.EnableRaisingEvents = true;

I developed the code on the same OS as the production environment (Win2k3) but I still came across an unexpected problem during testing in a pre-production environment. The server farm use DFS to synchronize the web site as well as my configuration file.  The FileSystemWatcher works perfectly on the machine where I modify the configuration file but the other machines in the server farm using FileSystemWatcher do not-get notified of changes in DFS.

It is possible to work around the problem by checking a time stamp but for now we do a manual file save operation on each machine until the problem gets fixed
:-(




Feel free to drop a few cents in the tip jar if this post saved you time and money

Post Comment
Title
 

Name
 

Url

Protected by Clearscreen.SharpHIPEnter the code you see:
Comment