Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to
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);


                    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 on Wednesday, September 20, 2006 7:55 AM ASP.NET | Back to top

Comments on this post: Unreliable in ASP.NET 2.0 Cache usage in MetaBuilders.DialogWindow

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: