开发者

ToolkitScriptManager throws NullReferenceException during concurrent access to a page for the first time

i'm developing a ASP.NET web application which uses the AjaxControlkit 开发者_运维技巧3.0.30512.20315. I have a ToolkitScriptManager instance on my master page which has some ScriptReferences in the CombineScripts collection. If i access my default page from 2 differenct clients after an iisreset, i get the following exception

[NullReferenceException: Object Reference not set to an instance of an object.]
   System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +143
   System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value) +11
   AjaxControlToolkit.ToolkitScriptManager.GetScriptCombineAttributes(Assembly assembly) +129
   AjaxControlToolkit.ToolkitScriptManager.IsScriptCombinable(ScriptEntry scriptEntry) +148
   AjaxControlToolkit.ToolkitScriptManager.OnResolveScriptReference(ScriptReferenceEventArgs e) +415
   System.Web.UI.ScriptManager.RegisterScripts() +191
   System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +113
   System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +8698462
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1029

Using .NET Reflector i found out that the GetScriptCombineAttributesmethod access a static dictionary, which is not protected against concurrent access. Either i have a race condition in my code or there is a bug in the AjaxToolkit.

Can anybody give me a hint on that one?

Thanks in advance


This bug was first officially reported on the ASP.NET AJAX Control Toolkit website on June 1 2010. The issue was closed as resolved on Jan 23 2013:

http://ajaxcontroltoolkit.codeplex.com/workitem/26752

Since it occurs within the Page portion of the ASP.NET pipeline, you could try overriding the OnPreRenderComplete method to implement a locking mechanism to block requests until the first one has completed successfully. Even the most light-weight implementation would impact every request, so you might choose to include it only on a login page or something (in a scenario where no other page would render anything since users weren't logged in). If the error is occurring all over your site the lock will probably wind up in a base class of every page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜