Unreliable in ASP.NET 2.0 Cache usage in MetaBuilders.DialogWindow

I am using  MetaBuilders.DialogWindow[^] and recently got
System.NullReferenceException: Object reference not set to an instance of an object.
at MetaBuilders.WebControls.DialogHandlerFactory.get_IsRegistered()
.

Investigation of the code showed that the problem related to the changed in ASP.NET 2.0 Cashe behavior - asyncronous Insert.
    if ( context.Cache[cacheKey] == null ) {
     context.Cache.Insert(cacheKey, DetermineIsRegistered());
    }
    return (Boolean)context.Cache[cacheKey];

The similar problem was known in DotNetNuke 4.0 (see my post).
The solution is the following:
                bool bRet=false;
                //fixed cache delay, do not rely on cache available immediately after insert
                if (context.Cache[cacheKey] == null
                {
                    bRet = DetermineIsRegistered();
                    context.Cache.Insert(cacheKey, bRet);
                }

                else

                    bRet = (Boolean)context.Cache[cacheKey];

                return bRet;

Related issue:Note that in ASP.NET 2.0 DialogHandlerFactory.DetermineIsRegistered should be changed as discussed in this thread to avoid System.ArgumentException: Object of type 'System.String' cannot be converted
to type 'System.Web.VirtualPath'.

 

 

posted @ Wednesday, September 20, 2006 7:55 AM
Print

Comments on this entry:

No comments posted yet.

Your comment:



(not displayed)

 
 
 
 
 

Live Comment Preview:

 
«September»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011