In FileBasedCachingProvider.vb, there are many lines of code like this:
Dim d As Caching.CacheDependency = Nothing
If PersistAppRestart And DataCache.CachePersistenceEnabled And Not objObject Is Nothing Then
d = New Caching.CacheDependency(f)
CreateCacheFile(f, objObject)
ElseIf WebFarmEnabled() Then
d = New Caching.CacheDependency(f)
CreateCacheFile(f)
Else
d = Nothing
End If
objCache.Insert(CacheKey, objObject, d)
These lines of code create a new CachingDependency with a filename parameter. And the cache file is created after that. So, the cache object will becomes obsolete right after the file is created. And the objCache.Insert(CacheKey, objObject, d) will have no effect, the object will not be inserted into cache.
I think we should create the file first, after that we create the CacheDependency object.