473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Caching problems in ASP.NET 2.0 beta 2

Is anyone using Caching (HttpRuntime.Ca che) 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,

BOSContext bosContext = new BOSContext();

StringBuilder Html = new StringBuilder() ;
if (bosContext.Con text.Cache[cacheKey] == null ||
!(bosContext.Co ntext.Cache[cacheKey] is StringBuilder))
{
if (xNav == null)
throw new Exception("Side Menu not initialised");
Html.Append("<T ABLE cellSpacing='0' cellPadding='0' width='100%'
border='0' class='" + cssClassTable + "'>");
xNav.MoveToRoot ();
xNav.MoveToFirs tChild();
DisplayTree(xNa v, 0);
Html.Append("</TABLE>");
System.Web.Cach ing.CacheDepend ency dep = new
System.Web.Cach ing.CacheDepend ency(_Filename) ;
bosContext.Cont ext.Cache.Inser t(cacheKey, Html, dep,
DateTime.Now.Ad dMinutes(15), System.Web.Cach ing.Cache.NoSli dingExpiration) ;
}
Html = ((StringBuilder ) bosContext.Cont ext.Cache[cacheKey]);

writer.WriteLin e(Html.ToString ()); //**

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 StringBuilder was null and instantiate it
there!
Nov 19 '05 #1
1 1312
To further question things.... I am getting random Object not found
Exceptions every now and then when running my code. Various objects are set
up to retrieve data in the way below, and occasionally they crash! I put in
the debug code below, and the exception thrown was "orig cache null-cache
null-". Does anyone have any idea how this can be possible!?

Thanks for any light that can be shed!

public static DataSet GetChambersData Set()

{

string strDebug = "";
BOSContext bosContext = BOSContext.Curr ent;
if (bosContext.Con text.Cache[ChamberDataSetC acheKey] == null)
{
strDebug = "orig cache null-";
BOSDataProvider dp = BOSDataProvider .Instance();
DataSet ds = dp.GetChambersD ataSet();
if (ds == null)
strDebug += "ds null-";
bosContext.Cont ext.Cache.Inser t(ChamberDataSe tCacheKey, ds,
null,DateTime.N ow.AddHours(1), System.Web.Cach ing.Cache.NoSli dingExpiration) ;
}
if (bosContext.Con text.Cache[ChamberDataSetC acheKey] == null)
strDebug += "cache null-";
else if (!(bosContext.C ontext.Cache[ChamberDataSetC acheKey] is DataSet))
strDebug += "cache type:" +
bosContext.Cont ext.Cache[ChamberDataSetC acheKey].GetType();
if (bosContext.Con text.Cache[ChamberDataSetC acheKey] == null)
throw new Exception(strDe bug);
return (DataSet)bosCon text.Context.Ca che[ChamberDataSetC acheKey];
}

"Gavin Pollock" <gp******@chall ow.removethis.n et> wrote in message
news:et******** ******@TK2MSFTN GP10.phx.gbl...
Is anyone using Caching (HttpRuntime.Ca che) 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,

BOSContext bosContext = new BOSContext();

StringBuilder Html = new StringBuilder() ;
if (bosContext.Con text.Cache[cacheKey] == null ||
!(bosContext.Co ntext.Cache[cacheKey] is StringBuilder))
{
if (xNav == null)
throw new Exception("Side Menu not initialised");
Html.Append("<T ABLE cellSpacing='0' cellPadding='0' width='100%'
border='0' class='" + cssClassTable + "'>");
xNav.MoveToRoot ();
xNav.MoveToFirs tChild();
DisplayTree(xNa v, 0);
Html.Append("</TABLE>");
System.Web.Cach ing.CacheDepend ency dep = new
System.Web.Cach ing.CacheDepend ency(_Filename) ;
bosContext.Cont ext.Cache.Inser t(cacheKey, Html, dep,
DateTime.Now.Ad dMinutes(15),
System.Web.Cach ing.Cache.NoSli dingExpiration) ;
}
Html = ((StringBuilder ) bosContext.Cont ext.Cache[cacheKey]);

writer.WriteLin e(Html.ToString ()); //**

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 StringBuilder was null and instantiate it
there!

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
1642
by: tshad | last post by:
How do we handle Caching in IE? It seems that my system works fine in Mozilla and Netscape when I make changes. But in IE the changes are not brought across when someone has been to the site before. If they have been here before and hit the same page, the old page is rendered which will cause errors as things that are expected with the...
0
1747
by: Rick Hein | last post by:
I've got a problem with an app I've been working on, the Caching object and events not firing correctly. In a nutshell: When I'm debugging, and I set a breakpoint in the removed item call back, the code works correctly. If there is no debugger it doesn't fire, which causes the app to have problems. Here's what the code does: The...
2
6093
by: George1776 | last post by:
All, I've recently upgraded our production ASP.NET/C# application from framework 1.1 to 2.0. Since then I've been plagued by out-of-memory errors and problems with the cache object (which may simply be a result of being out of memory.) We're running on IIS 5.1 on a single Windows 2000 server. We have a separate database server - SQL...
2
3147
by: Peter | last post by:
Hi The documentation for System.Web.Caching.Cache states that it is "thread safe". Does this mean that if I access System.Web.Caching.Cache from several places in my application access to the items in the cache is synchronised so I don't get problems with setting/getting the same item at the same time?
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.