Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / December 2004

Tip: Looking for answers? Try searching our database.

Caching problems in ASP.NET 2.0 beta 2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gavin Pollock - 06 Dec 2004 16:16 GMT
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!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.