none
System.ArgumentException: An item with the same key has already been added. RRS feed

  • Question

  • Hi,

    I have a project that using "LINQ to SQL" technology.  I was deal with this problem for a very long time.  This exception happen sometimes ( not always ) in my production environment.  I never met this problem in any of my development time or stage environment.  It just so weird.  Does anyone could explain what's going on this exception?

    Here is the exception details I collected using Application_Error method in Global.asax in my production environment:

    System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: An item with the same key has already been added.
    
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
    
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
    
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
    
       at System.Web.Query.Dynamic.ClassFactory.GetDynamicClass(IEnumerable`1 properties)
    
       at System.Web.Query.Dynamic.DynamicExpression.CreateClass(IEnumerable`1 properties)
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseNew()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseIdentifier()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParsePrimaryStart()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParsePrimary()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseUnary()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseMultiplicative()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseAdditive()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseComparison()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseLogicalAnd()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseLogicalOr()
    
       at System.Web.Query.Dynamic.ExpressionParser.ParseExpression()
    
       at System.Web.Query.Dynamic.ExpressionParser.Parse(Type resultType)
    
       at System.Web.Query.Dynamic.DynamicExpression.ParseLambda(ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
    
       at System.Web.Query.Dynamic.DynamicExpression.ParseLambda(Type itType, Type resultType, String expression, Object[] values)
    
       at System.Web.Query.Dynamic.DynamicQueryable.Select(IQueryable source, String selector, Object[] values)
    
       at System.Web.UI.WebControls.DynamicQueryableWrapper.Select(IQueryable source, String selector, Object[] values)
    
       at System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelectExpressions(IQueryable source, IDictionary`2 whereValues, IOrderedDictionary orderByOrderedValues, IDictionary`2 groupByValues, IDictionary`2 orderGroupsByValues, IDictionary`2 selectNewValues)
    
       at System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelectQuery(LinqDataSourceSelectEventArgs selectEventArgs, Object selectResult, Object table, Boolean storeOriginalValues)
    
       at System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
    
       at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
    
       at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
    
       at System.Web.UI.WebControls.ListView.PerformSelect()
    
       at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
    
       at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
    
       at System.Web.UI.WebControls.ListView.CreateChildControls()
    
       at System.Web.UI.Control.EnsureChildControls()
    
       at System.Web.UI.Control.PreRenderRecursiveInternal()
    
       at System.Web.UI.Control.PreRenderRecursiveInternal()
    
       at System.Web.UI.Control.PreRenderRecursiveInternal()
    
       at System.Web.UI.Control.PreRenderRecursiveInternal()
    
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    
       --- End of inner exception stack trace ---
    
       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.index_aspx.ProcessRequest(HttpContext context)
    
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    
    

     

    Wednesday, June 3, 2009 1:28 AM

All replies

  • This looks like a problem with the dynamic query library that you're using.

    You might want to upgrade your logging so that it records the actual query that you executed when this exception is thrown (including the parameters).

    Joe

    Write LINQ queries interactively - www.linqpad.net
    Wednesday, June 3, 2009 7:28 AM
    Answerer