asp.net mvc - MVC4 & EF5 System.ArgumentException: An item with the same key has already been added in ELMAH logs -
i getting "system.argumentexception: item same key has been added." in elmah log. application works fine on dev without exception. sure fields in entity have unique names. code:
[httppost] public actionresult create(candidate candidate) { if (modelstate.isvalid) { candidate.createdon=candidate.updatedon = datetime.now; db.candidates.add(candidate); db.savechanges(); //save original image & thumbnail if (request.files.count > 0) { candidate.photopath = persistimage(string.concat(candidate.name.split(' ')[0], "-", candidate.id.tostring())); candidate.resumepath = persistresume(string.concat(candidate.name.split(' ')[0], "-", candidate.id.tostring())); db.savechanges(); } membershipuser user = membership.getuser(candidate.userid); if (!user.isapproved) { user.isapproved = true; membership.updateuser(user); } tempdata.add("info", usermessages.success); formsauthentication.setauthcookie(candidate.userid, createpersistentcookie: false); return redirecttoaction("listing", "job"); } tempdata.add("info", usermessages.validationfailure); viewbag.categoryid = cachemanager.getcategoryselectlist(convert.tostring(convert.tostring(candidate.categoryid))); // viewbag.subcategoryid = new selectlist(db.subcategories, "id", "name", candidate.subcategoryid); viewbag.qualificationid = new selectlist(cachemanager.getqualifications(), "id", "name", candidate.qualificationid); viewbag.countryid = new selectlist(cachemanager.getcountries(), "id", "name", candidate.countryid); return view(candidate); }
stack trace:
system.argumentexception: item same key has been added. @ system.throwhelper.throwargumentexception(exceptionresource resource) @ system.collections.generic.dictionary`2.insert(tkey key, tvalue value, boolean add) @ ointerns.controllers.candidatecontroller.create(candidate candidate) @ lambda_method(closure , controllerbase , object[] ) @ system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) @ system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) @ system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass42.<begininvokesynchronousactionmethod>b__41() @ system.web.mvc.async.asyncresultwrapper.<>c__displayclass8`1.<beginsynchronous>b__7(iasyncresult _) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.end() @ system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethod(iasyncresult asyncresult) @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass37.<>c__displayclass39.<begininvokeactionmethodwithfilters>b__33() @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass4f.<invokeactionmethodfilterasynchronously>b__49() @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass4f.<invokeactionmethodfilterasynchronously>b__49() @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass4f.<invokeactionmethodfilterasynchronously>b__49() @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass37.<begininvokeactionmethodwithfilters>b__36(iasyncresult asyncresult) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.end() @ system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethodwithfilters(iasyncresult asyncresult) @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass25.<>c__displayclass2a.<begininvokeaction>b__20() @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass25.<begininvokeaction>b__22(iasyncresult asyncresult)
i have checked below thread of no avail
Comments
Post a Comment