From time to time, my clients gets this error.
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at AjaxControlToolkit.ToolkitScriptManager.GetScriptCombineAttributes(Assembly assembly)
at AjaxControlToolkit.ToolkitScriptManager.IsScriptCombinable(ScriptEntry scriptEntry)
at AjaxControlToolkit.ToolkitScriptManager.OnResolveScriptReference(ScriptReferenceEventArgs e)
at System.Web.UI.ScriptManager.RegisterScripts()
at System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e)
at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Comments: As evidenced by the recent September 2012 release, 'Microsoft has asked [...] Superexpert Consulting, to take ownership of the development and maintenance of the Ajax Control Toolkit' [blog](http://stephenwalther.com/archive/2011/05/02/ajax-control-toolkit-and-superexpert.aspx), and Superexpert Consulting is fixing issues in the Ajax Control Toolkit. I do not know if they get anything from Microsoft for this effort. Recognizing the need to transition away from the Ajax Control Toolkit is orthogonal to fixing issues that affect existing applications. The only reason I could think of for not fixing this issue was the inability to reproduce it reliably, which I [attached yesterday](http://ajaxcontroltoolkit.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=ajaxcontroltoolkit&WorkItemId=26752&FileAttachmentId=579736). This made it easier for me to test my attempts at a fix. As has been pointed out multiple times in the comments, CodePlex user etolmachev checked in a partial solution back in April 2011; the root cause was reported in Dec 2010 -- copied from a StackOverflow post made in May 2010. There has been almost no additional work required to fix this issue for between 1 to 2.5 years. I have submitted a [pull request](http://ajaxcontroltoolkit.codeplex.com/SourceControl/network/forks/jspraul/issue26752lock/contribution/3830) which locks all three of the static custom attribute dictionary caches in ToolkitScriptManager. This is only a slight tweak of etolmachev's fix, as recommended by CodePlex user Argawaen (John) below, and sacrifices a little performance for simplicity. I am attaching a build for .NET 3.5 and 4.0 which includes this fix (2012sep-ajaxcontroltoolkit-bin-2bbbad3d241c.zip).
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at AjaxControlToolkit.ToolkitScriptManager.GetScriptCombineAttributes(Assembly assembly)
at AjaxControlToolkit.ToolkitScriptManager.IsScriptCombinable(ScriptEntry scriptEntry)
at AjaxControlToolkit.ToolkitScriptManager.OnResolveScriptReference(ScriptReferenceEventArgs e)
at System.Web.UI.ScriptManager.RegisterScripts()
at System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e)
at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Comments: As evidenced by the recent September 2012 release, 'Microsoft has asked [...] Superexpert Consulting, to take ownership of the development and maintenance of the Ajax Control Toolkit' [blog](http://stephenwalther.com/archive/2011/05/02/ajax-control-toolkit-and-superexpert.aspx), and Superexpert Consulting is fixing issues in the Ajax Control Toolkit. I do not know if they get anything from Microsoft for this effort. Recognizing the need to transition away from the Ajax Control Toolkit is orthogonal to fixing issues that affect existing applications. The only reason I could think of for not fixing this issue was the inability to reproduce it reliably, which I [attached yesterday](http://ajaxcontroltoolkit.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=ajaxcontroltoolkit&WorkItemId=26752&FileAttachmentId=579736). This made it easier for me to test my attempts at a fix. As has been pointed out multiple times in the comments, CodePlex user etolmachev checked in a partial solution back in April 2011; the root cause was reported in Dec 2010 -- copied from a StackOverflow post made in May 2010. There has been almost no additional work required to fix this issue for between 1 to 2.5 years. I have submitted a [pull request](http://ajaxcontroltoolkit.codeplex.com/SourceControl/network/forks/jspraul/issue26752lock/contribution/3830) which locks all three of the static custom attribute dictionary caches in ToolkitScriptManager. This is only a slight tweak of etolmachev's fix, as recommended by CodePlex user Argawaen (John) below, and sacrifices a little performance for simplicity. I am attaching a build for .NET 3.5 and 4.0 which includes this fix (2012sep-ajaxcontroltoolkit-bin-2bbbad3d241c.zip).