HighTechTalks DotNet Forums  

Caching problems in ASP.NET 2.0 beta 2

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss Caching problems in ASP.NET 2.0 beta 2 in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Gavin Pollock
 
Posts: n/a

Default Caching problems in ASP.NET 2.0 beta 2 - 12-06-2004 , 11:16 AM






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),TimeSpa n.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!



Reply With Quote
  #2  
Old   
Ben Strackany
 
Posts: n/a

Default Re: Caching problems in ASP.NET 2.0 beta 2 - 12-07-2004 , 10:51 AM






If you wrap

if (userLookupTable[userKey] != null)

with a

if (userLookupTable!=null)

does it start working?

--
Ben Strackany
www.developmentnow.com


"Gavin Pollock" <gpollock (AT) challow (DOT) removethis.net> wrote

Quote:
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),TimeSpa n.Zero,System.Web.Caching.
CacheItemPriority.Normal,null);
Quote:
}
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!





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.