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!