XVAL和ASP.Net MVC 2 AddModelStateErrors问题 [英] xVal and ASP.Net MVC 2 AddModelStateErrors Problem

查看:137
本文介绍了XVAL和ASP.Net MVC 2 AddModelStateErrors问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我一直在使用XVAL成功了相当一段时间的应用程序。这是最近更新到MVC 2。

I have an application that I've been using xVal successfully on for quite some time. It was recently updated to MVC 2.

我用的是标准的DataAnnotations属性在我的域模型,这也实现调用的一个DataAnnotationsValidationRunner验证()方法。如果有任何错误,该方法将引发RulesException。

I use the standard DataAnnotations attributes on my domain models, which also implement a "Validate()" method that calls the DataAnnotationsValidationRunner. If there are any errors, that method throws a RulesException.

在我的控制器,我使用RulesException非常典型的抓

In my controllers, I use the very typical catch for RulesException

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

所有典型的东西,几乎直接从实例,并且做工精细直到最近(我怀疑开始在我的MVC1时间的问题 - > MVC2更新

All typical stuff, nearly straight from the examples, and working fine until recently (I suspect the problems started at the time of my MVC1 -> MVC2 update.

所以,问题是这样的:当AddModelStateErrors方法被调用,我得到一个System.EntryPointNotFoundException:入口点未找到,它是从未来了System.Collections.Generic.ICollection 1.get_Count()在System.Web.Mvc.Html.ValidationExtensions.ValidationMessageHelper(的HtmlHelper的HtmlHelper,modelMetadata modelMetadata,字符串前pression,字符串validationMessage,IDictionary的 2 htmlAttributes)在System.Web程序。 Mvc.Html.ValidationExtensions.ValidationMessage(的HtmlHelper的HtmlHelper,MODELNAME字符串,字符串validationMessage,IDictionary`2 htmlAttributes)在ASP.views_user_edit_aspx .__ RenderContent2 ... {剪断,因为它是标准的从那里}

So the problem is this: When the AddModelStateErrors method gets called, I'm getting a "System.EntryPointNotFoundException : Entry point was not found", which is coming from System.Collections.Generic.ICollection1.get_Count() at System.Web.Mvc.Html.ValidationExtensions.ValidationMessageHelper(HtmlHelper htmlHelper, ModelMetadata modelMetadata, String expression, String validationMessage, IDictionary2 htmlAttributes) at System.Web.Mvc.Html.ValidationExtensions.ValidationMessage(HtmlHelper htmlHelper, String modelName, String validationMessage, IDictionary`2 htmlAttributes) at ASP.views_user_edit_aspx.__RenderContent2...{snipped, as it's standard from there}

我已经看了两个code为XVAL的方法和扩展的HtmlHelper,我似乎无法弄清楚发生了什么事情。

I've looked at both the code for xVal's method and the HtmlHelper Extension, and I can't seem to figure out what's going on.

任何想法?

推荐答案

有同样的问题,但只是解决它:添加以下的web.config或app.config中,移动到MVC2:

Has the same problem but just solved it: add the following to web.config or app.config, for moving to 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>

这篇关于XVAL和ASP.Net MVC 2 AddModelStateErrors问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆