xVal 和 ASP.Net MVC 2 AddModelStateErrors 問題
我有一個應用程序,我已經成功使用 xVal 有一段時間了。它最近更新到 MVC 2。
我在我的域模型上使用標準的 DataAnnotations 屬性,它還實現了一個呼叫 DataAnnotationsValidationRunner 的“Validate()”方法。如果有任何錯誤,該方法將引發 RulesException。
在我的控制器中,我對 RulesException 使用了非常典型的 catch
catch (RulesException e) { e.AddModelStateErrors(ModelState, "err"); }所有典型的東西,幾乎直接來自範例,直到最近才正常工作(我懷疑問題是在我的 MVC1 -> MVC2 更新時開始的。
所以問題是這樣的:當呼叫 AddModelStateErrors 方法時,我得到一個“System.EntryPointNotFoundException:找不到入口點”,它來自
1.get_Count() at System.Web.Mvc.Html.ValidationExtensions.ValidationMessageHelper(HtmlHelper htmlHelper, ModelMetadata modelMetadata, String expression, String validationMessage, IDictionarySystem.Web.Mvc 的 System.Collections.Generic.ICollection 2 htmlAttributes .Html.ValidationExtensions.ValidationMessage(HtmlHelper htmlHelper, String modelName, String validationMessage, IDictionary`2 htmlAttributes) at ASP.views_user_edit_aspx.__RenderContent2…{被剪掉,因為它是那裡的標準}我已經查看了 xVal 方法的程式碼和 HtmlHelper 擴展,但我似乎無法弄清楚發生了什麼。
有任何想法嗎?
有同樣的問題,但剛剛解決了:將以下內容添加到 web.config 或 app.config,以移動到 MVC2:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime>或到 MVC3:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime>