xVal and ASP.Net MVC 2 AddModelStateErrors Problem
Asked Answered
W

1

8

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

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.

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

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

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.

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}

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.

Any ideas?

Wellbred answered 18/8, 2010 at 4:26 Comment(1)
Did you ever find a solution to this problem? We are having a similar issue upgrading MVC 1 => MVC 3Filamentous
A
6

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>

or to 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>
Auric answered 28/4, 2011 at 12:13 Comment(1)
thanks, this fixed a problem I was having. I still don't understand why it fixed it because I was referencing the v2 assembly, but putting in the v3 redirect solved the issue!Miele

© 2022 - 2024 — McMap. All rights reserved.