ASP.NET MVC 3 ActionDescriptor的ExtractParameterFromDictionary类型不匹配

开发人员反映同一个功能在开发服务器正常、测试服务器在满足一定操作条件后部分Action的model bind失败,之后无论如何操作直至应用程序池重启才恢复正常。查看异常日志如下:

Exception information: 
    Exception type: ArgumentException 
    Exception message: The parameters dictionary contains an invalid entry for parameter 'privilegeCode' for method 'System.Web.Mvc.JsonResult GetPrivilege(System.Collections.Generic.List`1[System.String], System.String)' in 'PerssionController'. The dictionary contains a value of type 'System.Collections.Generic.List`1[System.Web.Mvc.SelectListItem]', but the parameter requires a value of type 'System.Collections.Generic.List`1[System.String]'.
Parameter name: parameters
   at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo parameterInfo, IDictionary`2 parameters, MethodInfo methodInfo)
   at System.Web.Mvc.ReflectedActionDescriptor.<>c__DisplayClass1.<Execute>b__0(ParameterInfo parameterInfo)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

PerssionController的GetPrivilege函数需要一个字符串列表,但ActionDescriptor从参数字典中抽取返回时发现类型是SelectListItem列表。先用Fiddler2查看其中一个功能提交的数据没有问题,决定用WinDbg跟踪InvokeAction执行过程。开发人员又反映只在测试服务器有问题,怀疑是ASP.NET MVC 3版本问题,复制System.Web.Mvc.dll到Bin目录下但问题依旧。用WinDbg的lmv查看两台服务器上加载的System.Web.Mvc.dll,正常运行的版本为3.0.20105.0,错误的则为3.0.11209.0。安装AspNetMVC3ToolsUpdateSetup问题解决。

posted @ 2012-10-28 11:18  junchu25  阅读(448)  评论(0编辑  收藏  举报