C
Chris
I periodically, once every week or so, get an error when trying to read an
XML doc stored in cache. I get an 'object not set to a reference' I have a
gut feeling it happens when the app is under strain and the moment between
testing the cache and returning the cached xml doc it expires. I have read
several other people have the same problem. I have seen some C# code which
theoretically makes sense to me, but I don't understand the syntax and how
you would write it in VB.net. And I thought I had got me head round
"converting" C# ....... Can anyone explain it. I have tried:
Dim cacheitem as object = Cache(key) as XMLDocument
but with no luck. Here is the C# code in full.
Object cacheItem = Cache[key] as DataTable;
if(cacheItem == null)
{
cacheItem = GetData();
Cache.Insert(key, cacheItem, null, DateTime.Now.AddHours(1),
TimeSpan.Zero);
}
return (DataTable)cacheItem;
Regards, Chris.
XML doc stored in cache. I get an 'object not set to a reference' I have a
gut feeling it happens when the app is under strain and the moment between
testing the cache and returning the cached xml doc it expires. I have read
several other people have the same problem. I have seen some C# code which
theoretically makes sense to me, but I don't understand the syntax and how
you would write it in VB.net. And I thought I had got me head round
"converting" C# ....... Can anyone explain it. I have tried:
Dim cacheitem as object = Cache(key) as XMLDocument
but with no luck. Here is the C# code in full.
Object cacheItem = Cache[key] as DataTable;
if(cacheItem == null)
{
cacheItem = GetData();
Cache.Insert(key, cacheItem, null, DateTime.Now.AddHours(1),
TimeSpan.Zero);
}
return (DataTable)cacheItem;
Regards, Chris.