【发布时间】:2018-02-22 03:20:13
【问题描述】:
我使用System.Web.Caching 中的Cache 来缓存数据库中的一些数据。当我从Visual Studio 在本地机器上运行应用程序时,它工作正常。
但是当我在IIS 上运行它时,我在这一行得到Null pointer exception:
cache.Insert("Postnumbers", postnumbers, dependency,
DateTime.Now.AddDays(7), Cache.NoSlidingExpiration,
CacheItemPriority.Default, PostnumberRemovedCallback);
我检查了cache、postnumbers 和dependency,它们不为空。有谁知道什么会导致这个问题?
堆栈跟踪:
[NullReferenceException: Object reference not set to an instance of an object.]
Solvent.Model.Persistance.General.Entities.GeneralData.LoadPostnumbers() in C:\Solvent\Solvent\Solvent.Model\Persistance\General\Entities\GeneralData.cs:39
Solvent.Model.SolventInitializer.InitializeCache() in C:\Solvent\Solvent\Solvent.Model\Context\SolventInitializer.cs:153
Solvent.Model.SolventInitializer.Initialize() in C:\Solvent\Solvent\Solvent.Model\Context\SolventInitializer.cs:105
Solvent.MvcApplication.Application_Start() in C:\Solvent\Solvent\Solvent\Global.asax.cs:42
【问题讨论】:
-
显示完整的堆栈跟踪
-
@Fildor 缓存,postnumbers 和依赖不为空,我写的。
-
@haim770 我只得到这个:[NullReferenceException: 对象引用未设置为对象的实例。] 错误消息中没有更多信息。
-
@Aleksa 啊,超读缓存...抱歉。
-
@Aleksa 在第 X 行的 BlahDiBlubbb 中没有“...”?
标签: c# .net asp.net-mvc caching