我使用Cache
中的System.Web.Caching
来缓存数据库中的一些数据。当我从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
答案 0 :(得分:1)
我解决了。我将./1#1#d41d8cd98f00b204e9800998ecf8427e
./1#2#d41d8cd98f00b204e9800998ecf8427e
./11.txt#2#d41d8cd98f00b204e9800998ecf8427e
./12/1#1#d41d8cd98f00b204e9800998ecf8427e
./12/1#2#d41d8cd98f00b204e9800998ecf8427e
./12/1.txt#1#d41d8cd98f00b204e9800998ecf8427e
./12/1.txt#2#d41d8cd98f00b204e9800998ecf8427e
./12/2.txt#1#d41d8cd98f00b204e9800998ecf8427e
./12/2.txt#2#d41d8cd98f00b204e9800998ecf8427e
./13#2#d41d8cd98f00b204e9800998ecf8427e
./2.txt#1#5d74727d50368c4741d76989586d91de
./2.txt#2#5d74727d50368c4741d76989586d91de
替换为var cache = new Cahce(); cache.Insert()
。
但我仍然不知道为什么第一种方式适用于本地而非生产。