FileSystemWatcher does not work with DFS on Win2k3
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