Throws an exception: an element with the same key already exists in the dictionary

2 posts, 0 answers
  1. Robert
    Robert avatar
    2 posts
    Member since:
    Jul 2010

    Posted 18 Jul 2010 Link to this post

    Hi everybody,
    Using two controls RadRotator and RadMenu on the one and the same page we've met the following problem: from time to time an exception is thrown. We are using Telerik RadControls for ASP.NET Ajax controls version 2009.2.826.35. The stack trace and technical information are below:

    Source:
    mscorlib

    StackTrace:
    в System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) в System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) в Telerik.Web.UI.Common.ControlRenderer.GetUrl(Control controlRef, String resourceName) в Telerik.Web.UI.Common.ControlRenderer.GetControlScripts(Control controlRef) в Telerik.Web.UI.RadDataBoundControl.RenderScriptsNoScriptManager(HtmlTextWriter writer) в Telerik.Web.UI.RadDataBoundControl.Render(HtmlTextWriter writer) в System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer) в System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) в System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) в System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) в System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) в System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer) в System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) в System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) в System.Web.UI.Control.Render(HtmlTextWriter writer) в System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer) в ASP.main_master.__RendermainForm(HtmlTextWriter __w, Control parameterContainer) в System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) в System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) в System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) в System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) в System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) в System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) в System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) в System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) в System.Web.UI.Control.Render(HtmlTextWriter writer) в System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer) в System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) в System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) в System.Web.UI.Page.Render(HtmlTextWriter writer) в System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer) в System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    TargetSite:
    ThrowArgumentException

    InnerExceptionMessage:
    null

    RequestInfo:
    UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
    UserLanguages: ru-RU

    Will appreciate any help.
    Thanks.
  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 21 Jul 2010 Link to this post

    Hello Robert,

    I tested the following code and everything seems to be working fine. Could you please provide a sample project where we can observe and debug the issue?
    .aspx
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            </Scripts>
        </asp:ScriptManager>
        <div>
            <asp:Button ID="Button1" runat="server" Text="Postback" />
        </div>
        <telerik:RadMenu ID="Menu1" runat="server">
            <Items>
                <telerik:RadMenuItem Text="Item 1">
                    <Items>
                        <telerik:RadMenuItem Text="Item 2">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Item 3">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Item 4">
                        </telerik:RadMenuItem>
                    </Items>
                </telerik:RadMenuItem>
                <telerik:RadMenuItem Text="Item 2">
                    <Items>
                        <telerik:RadMenuItem Text="Item 2">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Item 3">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Item 4">
                        </telerik:RadMenuItem>
                    </Items>
                </telerik:RadMenuItem>
                <telerik:RadMenuItem Text="Item 3">
                    <Items>
                        <telerik:RadMenuItem Text="Item 2">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Item 3">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Item 4">
                        </telerik:RadMenuItem>
                    </Items>
                </telerik:RadMenuItem>
                <telerik:RadMenuItem Text="Item 4">
                    <Items>
                        <telerik:RadMenuItem Text="Item 2">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Item 3">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Item 4">
                        </telerik:RadMenuItem>
                    </Items>
                </telerik:RadMenuItem>
            </Items>
        </telerik:RadMenu>
        <telerik:RadRotator ID="Image_Rotator" runat="server" CssClass="image_rotator" Width="100"
            Height="100" ScrollDirection="Up" ScrollDuration="1000" RotatorType="AutomaticAdvance"
            FrameDuration="1000" PauseOnMouseOver="false" ItemWidth="100" ItemHeight="100">
            <ItemTemplate>
                <div style="border: 1px solid red; width: 100%; height: 100%;">
                    <span>
                        <%#Container.DataItem.ToString()%></span>
                </div>
            </ItemTemplate>
        </telerik:RadRotator>
        </form>
    </body>
    </html>

    .cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;
     
    public partial class Default_Rotator : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Image_Rotator.DataSource = new string[] { "Item 0", "Item 1", "Item 2", "Item 3", "Item 4", "Item 0", "Item 5", "Item 6", "Item 7", "Item 8" };
            Image_Rotator.DataBind();
        }
    }


    Sincerely yours,
    Pero
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top