Wednesday, March 28, 2012

PageMethod Exception: "An entry with the same key already exists."

I am calling a PageMethod from a javascript function. This function is called from many different controls on a page. The problem occurs about the second time the method is called. An exception is thrown saying that an entry with the same key already exists. The weird thing is that everything continues to work normally from the users perspective. I would never have noticed this behaviour if I hadn't be debugging. Its more annoying than developement breaking, but I would still like a solution to it. Except I have no idea how to proceed. Am I just using PageMethod improperly?

I'm using ASP.NET 2.0 with C# code.

My config file says this about the assembly I'm using: System.Web.Extensions, Version=1.0.61025.0

Stack trace follows...

EXCEPTION:

{"Error executing child request for /thesite/problemLog.aspx."}

STACK: atSystem.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler,TextWriter writer, Boolean preserveForm, Boolean setPreviousPage,VirtualPath path, VirtualPath filePath, String physPath, Exceptionerror, String queryStringOverride)
at System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path)
at ASP.global_asax.Application_Error(Object sender, EventArgs e) in c:\Projects\Velocity Code\cfdrodeo\Global.asax:line 92
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.HttpApplication.RaiseOnError()

INNER EXCEPTION:

{"Exception of type 'System.Web.HttpUnhandledException' was thrown."}

STACK:

at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.problemlog_aspx.ProcessRequest(HttpContext context) inc:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NETFiles\cfdrodeo\0b93ea50\5991e932\App_Web_xczsyy3k.22.cs:line 0
at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandlerhandler, TextWriter writer, Boolean preserveForm, BooleansetPreviousPage, VirtualPath path, VirtualPath filePath, StringphysPath, Exception error, String queryStringOverride)

INNER EXCEPTION:

{"An entry with the same key already exists."}

STACK:

at System.Collections.Specialized.ListDictionary.Add(Object key, Object value)
at System.Web.UI.ClientScriptManager.RegisterScriptBlock(ScriptKey key, String script, ListDictionary& scriptBlocks, ArrayList& scriptList, Boolean needsScriptTags, Boolean& inScriptBlock)
at System.Web.UI.ClientScriptManager.RegisterScriptBlock(ScriptKey key, String script, ClientAPIRegisterType type)
at System.Web.UI.ClientScriptManager.RegisterClientScriptInclude(Type type, String key, String url)
at System.Web.UI.ScriptRegistrationManager.RegisterClientScriptInclude(Control control, Type type, String key, String url)
at System.Web.UI.ScriptManager.RegisterClientScriptInclude(Control control, Type type, String key, String url)
at System.Web.UI.ScriptManager.RegisterClientScriptIncludeInternal(Control control, Type type, String key, String url)
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.PerformPreRenderComplete()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Thank you for your help.

Hi,

could you post the code of your page method and the JavaScript code that you use to invoke it?

No comments:

Post a Comment