System.ArgumentException in Lib.Web.Mvc 4.3.0

Dec 7, 2011 at 4:03 AM

We've been using Lib.Web.Mvc 4.1.1 and it's been working great.  Today I tried to update to Lib.Web.Mvc 4.3.0 and received the following error:

System.ArgumentException was unhandled by user code
  Message=An item with the same key has already been added.

I also downloaded and tried 4.2.0 and it works fine; the issue seems to be with 4.3.0.  I've included the relevant part of the stack trace below.  I believe the issue is in JqGridModelMetadataExtensions.SetColumnDateFormat, but have not spent any time in the source yet trying to determine what's wrong.

The model is pretty simple, only 4 properties, one int and the other four strings.  None are dates.  There is one property named ActiveDate and the DisplayName is "Active Date"; can't imagine that would be the source of the issue but it is the only way thing I see in the model that might have reference to date.  I've included the full model below if that helps.

Thanks.  Karl.

       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 Lib.Web.Mvc.JQuery.JqGrid.DataAnnotations.JqGridModelMetadataExtensions.SetColumnDateFormat(ModelMetadata metadata, String dateFormat)
       at Lib.Web.Mvc.JQuery.JqGrid.DataAnnotations.JqGridColumnElementAttribute.OnMetadataCreated(ModelMetadata metadata)
       at System.Web.Mvc.AssociatedMetadataProvider.ApplyMetadataAwareAttributes(IEnumerable`1 attributes, ModelMetadata result)
       at System.Web.Mvc.AssociatedMetadataProvider.GetMetadataForProperty(Func`1 modelAccessor, Type containerType, PropertyDescriptor propertyDescriptor)
       at System.Web.Mvc.AssociatedMetadataProvider.<GetMetadataForPropertiesImpl>d__2.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at Lib.Web.Mvc.JQuery.JqGrid.JqGridOptions`1..ctor(String id)
       at Lib.Web.Mvc.JQuery.JqGrid.JqGridHelper`1..ctor(String id, String afterInsertRow, String afterEditCell, String afterRestoreCell, String afterSaveCell, String afterSubmitCell, String altClass, Boolean altRows, Boolean autoEncode, Boolean autoWidth, String beforeRequest, String beforeSelectRow, String beforeEditCell, String beforeSaveCell, String beforeSubmitCell, String caption, Int32 cellLayout, Boolean cellEditingEnabled, JqGridCellEditingSubmitModes cellEditingSubmitMode, String cellEditingUrl, String dataString, JqGridDataTypes dataType, Boolean deepEmpty, JqGridLanguageDirections direction, JqGridDynamicScrollingModes dynamicScrollingMode, Int32 dynamicScrollingTimeout, String editingUrl, Boolean expandColumnClick, String expandColumn, Nullable`1 height, String errorCell, String formatCell, Boolean footerEnabled, Boolean groupingEnabled, JqGridGroupingView groupingView, Boolean hidden, Boolean hiddenEnabled, JqGridJsonReader jsonReader, String loadBeforeSend, String loadError, String loadComplete, Boolean loadOnce, JqGridMethodTypes methodType, Nullable`1 multiKey, Boolean multiBoxOnly, Boolean multiSelect, Int32 multiSelectWidth, String gridComplete, String onCellSelect, String onDoubleClickRow, String onHeaderClick, String onPaging, String onRightClickRow, String onSelectAll, String onSelectCell, String onSelectRow, String onSortCol, Boolean pager, JqGridParametersNames parametersNames, String resizeStart, String resizeStop, List`1 rowsList, Int32 rowsNumber, Boolean rowsNumbers, Int32 rowsNumbersWidth, Boolean shrinkToFit, Int32 scrollOffset, String serializeCellData, String serializeGridData, String serializeSubGridData, String sortingName, JqGridSortingOrders sortingOrder, Boolean subgridEnabled, JqGridSubgridModel subgridModel, String subgridUrl, Int32 subgridColumnWidth, String subGridBeforeExpand, String subGridRowColapsed, String subGridRowExpanded, Boolean topPager, Boolean treeGridEnabled, JqGridTreeGridModels treeGridModel, String url, Boolean userDataOnFooter, Boolean viewRecords, Nullable`1 width)

public class TestItem
 public int TestId { get; set; }

 [JqGridColumnLayout(Alignment = JqGridAlignments.Left, Width = 100, Fixed = true, Resizable = false)]
 public string TestType { get; set; }

 [JqGridColumnLayout(Alignment = JqGridAlignments.Center, Width = 160, Fixed = true, Resizable = false)]
 public string Comment { get; set; }

 [JqGridColumnLayout(Alignment = JqGridAlignments.Center, Width = 160, Fixed = true, Resizable = false)]
 public string Action { get; set; }

 [DisplayName("Active Date")]
 [JqGridColumnLayout(Alignment = JqGridAlignments.Center, Width = 80, Fixed = true, Resizable = false)]
 public string ActiveDate { get; set; }

Dec 7, 2011 at 7:32 AM

Thank you for detailed description. I will look into this today and hopefully realease a bug fix version.

Dec 7, 2011 at 8:19 PM

Bug has been identified and fixed in Lib.Web.Mvc v4.3.1

Dec 7, 2011 at 8:20 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.