小编ado*_*-mg的帖子

使用带有 HostFileChangeMonitor init 的 MemoryCache 到目录会得到 ArgumentOutOfRangeException

我正在使用 .NET 4 的 System.Runtime.Caching 中的 MemoryCache,我希望在目录更改时使缓存条目无效。

HostFileChangeMonitor 应该处理文件和目录,所以我像这样添加它:

var cacheItemPolicy = new CacheItemPolicy { SlidingExpiration = TimeSpan.FromMinutes(30) };
cacheItemPolicy.ChangeMonitors.Add(new HostFileChangeMonitor(new List<string> { folder }));
Run Code Online (Sandbox Code Playgroud)

但后来我得到一个例外:

System.ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000.
Run Code Online (Sandbox Code Playgroud)

仅当我在 ASP.NET 网站中使用代码时才会发生这种情况。它在控制台应用程序内部工作正常。

我在 ms connect 上发现了这个,但是我添加到 HostFileChangeMonitor 的目录存在。

谢谢你的帮助。

asp.net memorycache

5
推荐指数
1
解决办法
2294
查看次数

标签 统计

asp.net ×1

memorycache ×1