问题描述
已添加了具有相同键的项。说明:执行当前Web请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息:System.ArgumentException:已添加了具有相同键的项。源错误:执行当前Web请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。堆栈跟踪:[ArgumentException:已添加了具有相同键的项。]System.ThrowHelper.ThrowArgumentException(ExceptionResourceresource)+52System.Collections.Generic.Dictionary`2.Insert(TKeykey,TValuevalue,Booleanadd)+9381419System.Linq.Enumerable.ToDictionary(IEnumerable`1source,Func`2keySelector,Func`2elementSelector,IEqualityComparer`1comparer)+252System.Linq.Enumerable.ToDictionary(IEnumerable`1source,Func`2keySelector,IEqualityComparer`1comparer)+91System.Web.Mvc.ModelBindingContext.get_PropertyMetadata()+157System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContextcontrollerContext,ModelBindingContextbindingContext,PropertyDescriptorpropertyDescriptor)+223System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContextcontrollerContext,ModelBindingContextbindingContext)+93System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContextcontrollerContext,ModelBindingContextbindingContext,Objectmodel)+53System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContextcontrollerContext,ModelBindingContextbindingContext)+1367System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContextcontrollerContext,ModelBindingContextbindingContext)+449System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContextcontrollerContext,ParameterDescriptorparameterDescriptor)+317System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContextcontrollerContext,ActionDescriptoractionDescriptor)+117System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContextcontrollerContext,StringactionName)+343System.Web.Mvc.Controller.ExecuteCore()+116System.Web.Mvc.ControllerBase.Execute(RequestContextrequestContext)+97System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContextrequestContext)+10System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5()+37System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0()+21System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult_)+12System.Web.Mvc.Async.WrappedAsyncResult`1.End()+62System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d()+50System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Actionf)+7System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Actionaction)+22System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResultasyncResult)+60System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResultresult)+9System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+9042173System.Web.HttpApplication.ExecuteStep(IExecutionStepstep,Boolean&completedSynchronously)+184
解决方案
解决方案二:
看错误像是绑定Model时有问题*****************************************************************************签名档:http://feiyun0112.cnblogs.com/
解决方案三:
晕啊能结贴吗
解决方案四:
给个解决方案给我再结贴啊。
解决方案五:
很明显key重复了啊你起码贴出出错地方的代码才能给你看吧
解决方案六:
IDictionary<TKey,TValue>.Add方法(TKey,TValue)在添加键值对之前应该先判断是否已经存在该键,可以用ContainsKey方法判断,ContainsKey(键);如果已经存在该键,就直接赋值:dic[键]=值;如果不存在该键,就调用Add方法添加,dic.Add(键,值).
解决方案七:
出错误的地方varurl="/WlSearEdit/List?WFlows_Term_id="+$("#WFlows_Term_id").val()+"&WFlows_user_name="+$("#WFlows_user_name").val()+"&WFlows_state="+$("#WFlows_state").val()+"&WFlows_type="+WFlows_type+"&WFlows_org="+$("#WFlows_org").val()+"&WFlows_deal_person="+$("#WFlows_deal_person").val()+"&Delsite_id="+delsite_id+"&pagetype=Details"+"&time="+newDate().getTime();if($("#WFlows_state00").get(0).checked){url="/WlSearEdit/List?WFlows_Term_id="+$("#WFlows_Term_id").val()+"&WFlows_user_name="+$("#WFlows_user_name").val()+"&WFlows_state=00"+"&WFlows_type="+WFlows_type+"&WFlows_org="+$("#WFlows_org").val()+"&Delsite_id="+delsite_id+"&pagetype=Details"+"&time="+newDate().getTime();}alert(url);parent.addTab("任务详情",url,"");
解决方案八:
你这给的前端代码,错误明显是后端的呀!
解决方案:
publicActionResultList(E3S_WorkList_FlowsS_EWF,stringDelsite_id,int?page,stringpagetype="")
解决方案:
publicclassE3S_WorkList_Flows{[DataObjectField(true)][DisplayName("终端编号")]publicstringWFlows_Term_id{get;set;}[DataObjectField(true)][DisplayName("请求时间")][Description("查询条件:Compare")]publicstringWFlows_gen_date{get;set;}[DataObjectField(true)][DisplayName("工单批次号")]publicstringWFlows_id{get;set;}privatestring_WFlows_type;[DataObjectField(true)][DisplayName("工单类型")][Description("DIC:04+Dic_data")]publicstringWFlows_type{get{return_WFlows_type;}set{_WFlows_type=string.IsNullOrEmpty(value)?"":value.Trim();WFlows_type_name=newDICT().GetDictFromBufByTypeData("0000000004",_WFlows_type).Dic_name;}}privatestring_WFlows_state;[DisplayName("工单状态")][Description("查询条件:IN")]publicstringWFlows_state{get{return_WFlows_state;}set{_WFlows_state=string.IsNullOrEmpty(value)?"":value.Trim();WFlows_state_name=newDICT().GetDictFromBufByTypeData("0000000005",_WFlows_state).Dic_name;}}[DisplayName("派单人")][Description("查询条件:IN")]publicstringWFlows_Allocation_person{get;set;}[DisplayName("工单分配日期")][Description("查询条件:Compare")]publicstringWFlows_Allocation_date{get;set;}[DisplayName("所有人")][Description("查询条件:IN")]publicstringWFlows_deal_person{get;set;}[DisplayName("工单完成日期/时间")][Description("查询条件:Compare")]publicstringWFlows_end_time{get;set;}[DisplayName("客户姓名")]publicstringWFlows_user_name{get;set;}[DisplayName("工单号")]publicstringWFlows_Workid{get;set;}[DisplayName("服务诉求")]publicstringService_demand{get;set;}privatestring_Door_to_door;[DisplayName("是否上门")]publicstringDoor_to_door{get{return_Door_to_door;}set{_Door_to_door=string.IsNullOrEmpty(value)?"":value.Trim();Door_to_door_name=newDICT().GetDictFromBufByTypeData("0000000021",_Door_to_door).Dic_name;}}[DisplayName("用户地址")]publicstringWFlows_address{get;set;}[DisplayName("开户支行")][Description("查询条件:LEqual")]publicstringWFlows_org{get;set;}privatestring_Handle;[DisplayName("是否处理")]publicstringHandle{get{return_Handle;}set{_Handle=string.IsNullOrEmpty(value)?"":value.Trim();Handle_name=newDICT().GetDictFromBufByTypeData("0000000021",_Handle).Dic_name;}}[DisplayName("上次巡检日期/时间")]publicstringWFlows_last_view_time{get;set;}[DisplayName("下次巡检日期/时间")]publicstringWFlows_next_view_time{get;set;}privatestring_Solve;[DisplayName("是否解决")]publicstringSolve{get{return_Solve;}set{_Solve=string.IsNullOrEmpty(value)?"":value.Trim();Solve_name=newDICT().GetDictFromBufByTypeData("0000000021",_Solve).Dic_name;}}privatestring_Transactions;[DisplayName("是否交易")]publicstringTransactions{get{return_Transactions;}set{_Transactions=string.IsNullOrEmpty(value)?"":value.Trim();Transactions_name=newDICT().GetDictFromBufByTypeData("0000000021",_Transactions).Dic_name;}}privatestring_Amount_transaction;[DisplayName("交易金额")]publicstringAmount_transaction{get{return_Amount_transaction;}set{_Amount_transaction=string.IsNullOrEmpty(value)?"":value.Trim();Amount_transaction_name=newDICT().GetDictFromBufByTypeData("0000000022",_Amount_transaction).Dic_name;}}privatestring_Service;[DisplayName("服务情况")]publicstringService{get{return_Service;}set{_Service=string.IsNullOrEmpty(value)?"":value.Trim();Service_name=newDICT().GetDictFromBufByTypeData("0000000020",_Service).Dic_name;}}[DisplayName("解决办法")]publicstringSolution{get;set;}[DisplayName("备注")]publicstringMemo{get;set;}[DisplayName("响应时间")]publicstringResponse_date{get;set;}[Description("外键:工单类型")]//外键publicstringWFlows_type_name{get;set;}[Description("外键:工单状态")]//外键publicstringWFlows_state_name{get;set;}[Description("外键:开户支行")]//外键publicstringWFlows_org_name{get;set;}[Description("外键:所有人")]//外键publicstringWFlows_User_Name{get;set;}[Description("外键:服务情况")]//外键publicstringService_name{get;set;}[Description("外键:交易金额")]//外键publicstringAmount_transaction_name{get;set;}[Description("外键:是否交易")]//外键publicstringTransactions_name{get;set;}[Description("外键:是否解决")]//外键publicstringSolve_name{get;set;}[Description("外键:是否处理")]//外键publicstringHandle_name{get;set;}[Description("外键:是否上门")]//外键publicstringDoor_to_door_name{get;set;}
解决方案:
解决了吗?!!!!!!!
解决方案:
解决了,MODEL中的字段定义错误。
解决方案:
可喜可贺——我是厚颜无耻,来接分的。
解决方案:
好贴,我也遇到这个问题了,再仔细检查下model的定义
解决方案:
是Model中有重复定义的项。楼上正解!!