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!