I am using MemoryCache from System.Runtime.Caching of .NET 4 and I wish to invalidate the cache entry when a directory changes.
HostFileChangeMonitor is supposed to handle both files and directories so I am adding it like so:
var cacheItemPolicy = new CacheItemPolicy { SlidingExpiration = TimeSpan.FromMinutes(30) };
cacheItemPolicy.ChangeMonitors.Add(new HostFileChangeMonitor(new List<string> { folder }));
but then I get an exception:
System.ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000.
This only happens if I use the code in a ASP.NET website. It works fine from inside a console application.
I have found this on ms connect, but the directory I am adding to the HostFileChangeMonitor exists.
Thanks for your help.
To answer my own question:
it seems that 4.0 has a bug when adding Directories to the HostFileChangeMonitor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With