Is anyone using Caching (HttpRuntime.Cache) in Whidbey? Not sure if there's
another newsgroup for this though since it's still beta....
I'm having issues running a system built on 1.1 in a 2.0 environment...
Simple (I think!!) use of the Cache as below,
if (HttpRuntime.Cache[cacheKey] == null)
{
HttpRuntime.Cache.Add(cacheKey, new
Hashtable(),null,DateTime.Now.AddMonths(1),TimeSpan.Zero,System.Web.Caching.CacheItemPriority.Normal,null);
}
userLookupTable = (Hashtable) HttpRuntime.Cache[cacheKey];
userKey = "User-" + username;
if (userLookupTable[userKey] != null) //**
{
return (User) userLookupTable[userKey];
}
And the system is crashing on the //** line with "Object reference not set
to an instance of an object.". I would've thought that the check in the
first line would capture if the Hashtable was null and instantiate it there!
Ben Strackany - 07 Dec 2004 15:51 GMT
If you wrap
if (userLookupTable[userKey] != null)
with a
if (userLookupTable!=null)
does it start working?

Signature
Ben Strackany
www.developmentnow.com
> Is anyone using Caching (HttpRuntime.Cache) in Whidbey? Not sure if there's
> another newsgroup for this though since it's still beta....
[quoted text clipped - 5 lines]
> {
> HttpRuntime.Cache.Add(cacheKey, new
Hashtable(),null,DateTime.Now.AddMonths(1),TimeSpan.Zero,System.Web.Caching.
CacheItemPriority.Normal,null);
> }
> userLookupTable = (Hashtable) HttpRuntime.Cache[cacheKey];
[quoted text clipped - 7 lines]
> to an instance of an object.". I would've thought that the check in the
> first line would capture if the Hashtable was null and instantiate it there!