我有一个我已经成功使用XVAL的应用程序了一段时间。最近已更新为MVC 2。

我在我的域模型上使用标准dataantations属性,该属性还实现了一种称为dataAnnotationsValidationRunner的“ Validate()”方法。如果有任何错误,该方法会引发leseSexception。

在我的控制器中,我使用非常典型的捕获来进行ruleSexception

catch (RulesException e)
{
    e.AddModelStateErrors(ModelState, "err");
}

所有典型的东西,几乎直接从示例中直接工作,直到最近才能正常工作(我怀疑问题始于我的MVC1-> MVC2更新时。

因此问题是:当addModelStateErrors方法被调用时,我将获得一个“ system.entrypointnotfoundexception:未找到输入点”,它来自system.collections.generic.generic.icollection。1.get_Count() at System.Web.Mvc.Html.ValidationExtensions.ValidationMessageHelper(HtmlHelper htmlHelper, ModelMetadata modelMetadata, String expression, String validationMessage, IDictionary2 htmlattributes)在system.web.mvc.html.validationextensions.validationmessage(htmlhelper htmlhelper,字符串模型名称,字符串验证message,indictionary`2 htmlattributes)

我已经查看了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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top