I have a bunch of simple lookup tables cached in my asp.net application, since the source data is on a separate server from our main web architecture and does not change often. I read the answers and various documentation here, and I have a boot function that calls the following:
HttpContext.Current.Cache.Insert("CheckLocations", GetAllCheckLocations(), _
Nothing, DateAdd(DateInterval.Day, 1, Now()), _
System.Web.Caching.Cache.NoSlidingExpiration, _
CacheItemPriority.Normal, _
New CacheItemRemovedCallback(AddressOf CheckLocationsExpired))
For my expired cache callback, I have the following code.
Public Shared Sub CheckLocationsExpired(ByVal key As String, ByVal value As Object, ByVal reason As CacheItemRemovedReason)
Dim dtCheckLocation As New ReferenceSchema.CheckLocationDataTable
dtCheckLocation = GetAllCheckLocations()
HttpContext.Current.Cache.Insert("CheckLocations", dtCheckLocation, Nothing, _
DateAdd(DateInterval.Day, 1, Now()), _
System.Web.Caching.Cache.NoSlidingExpiration, _
CacheItemPriority.Normal, _
New CacheItemRemovedCallback(AddressOf CheckLocationsExpired))
End Sub
For the record, the GetAllCheckLocations method simply calls the web service and parses the results in the stored data table.
Now, when I recompile the application for local testing, everything still works fine, but in my log file I found the following exception message:
System.NullReferenceException: . EAF.CacheMethods.CheckLocationsExpired( , , CacheItemRemovedReason) C:\Projects\HR\EAF 2.0\DAL\CacheMethods.vb: 434 System.Web.Caching.CacheEntry.CallCacheItemRemovedCallback(CacheItemRemovedCallback , CacheItemRemovedReason)
, , .
- , ? "", Reponse.Redirect, ?