473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Caching problems in ASP.NET 2.0 beta 2

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,

BOSContext bosContext = new BOSContext();

StringBuilder Html = new StringBuilder();
if (bosContext.Context.Cache[cacheKey] == null ||
!(bosContext.Context.Cache[cacheKey] is StringBuilder))
{
if (xNav == null)
throw new Exception("Side Menu not initialised");
Html.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%'
border='0' class='" + cssClassTable + "'>");
xNav.MoveToRoot();
xNav.MoveToFirstChild();
DisplayTree(xNav, 0);
Html.Append("</TABLE>");
System.Web.Caching.CacheDependency dep = new
System.Web.Caching.CacheDependency(_Filename);
bosContext.Context.Cache.Insert(cacheKey, Html, dep,
DateTime.Now.AddMinutes(15), System.Web.Caching.Cache.NoSlidingExpiration);
}
Html = ((StringBuilder) bosContext.Context.Cache[cacheKey]);

writer.WriteLine(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 1302
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 GetChambersDataSet()

{

string strDebug = "";
BOSContext bosContext = BOSContext.Current;
if (bosContext.Context.Cache[ChamberDataSetCacheKey] == null)
{
strDebug = "orig cache null-";
BOSDataProvider dp = BOSDataProvider.Instance();
DataSet ds = dp.GetChambersDataSet();
if (ds == null)
strDebug += "ds null-";
bosContext.Context.Cache.Insert(ChamberDataSetCach eKey, ds,
null,DateTime.Now.AddHours(1),System.Web.Caching.C ache.NoSlidingExpiration);
}
if (bosContext.Context.Cache[ChamberDataSetCacheKey] == null)
strDebug += "cache null-";
else if (!(bosContext.Context.Cache[ChamberDataSetCacheKey] is DataSet))
strDebug += "cache type:" +
bosContext.Context.Cache[ChamberDataSetCacheKey].GetType();
if (bosContext.Context.Cache[ChamberDataSetCacheKey] == null)
throw new Exception(strDebug);
return (DataSet)bosContext.Context.Cache[ChamberDataSetCacheKey];
}

"Gavin Pollock" <gp******@challow.removethis.net> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
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,

BOSContext bosContext = new BOSContext();

StringBuilder Html = new StringBuilder();
if (bosContext.Context.Cache[cacheKey] == null ||
!(bosContext.Context.Cache[cacheKey] is StringBuilder))
{
if (xNav == null)
throw new Exception("Side Menu not initialised");
Html.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%'
border='0' class='" + cssClassTable + "'>");
xNav.MoveToRoot();
xNav.MoveToFirstChild();
DisplayTree(xNav, 0);
Html.Append("</TABLE>");
System.Web.Caching.CacheDependency dep = new
System.Web.Caching.CacheDependency(_Filename);
bosContext.Context.Cache.Insert(cacheKey, Html, dep,
DateTime.Now.AddMinutes(15),
System.Web.Caching.Cache.NoSlidingExpiration);
}
Html = ((StringBuilder) bosContext.Context.Cache[cacheKey]);

writer.WriteLine(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
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...
0
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...
2
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.