I upgraded my MVC application from MVC 3 to 5.2.2 and now I'm getting this error. I've made a brand new MVC project using the new project wizard and this works, and I've compared my /web.config
and Views/web.config
files across the two projects and don't see any differences that seem important.
Looking in the object browser, I see that there are in fact two different HtmlHelper
objects defined in System.Web.WebPages
and System.Web.Mvc
, which seems relevant:
But I'm not sure what to do with this fact.
After wrestling with this for hours and then posting the question here, I figured it out a minute later; I had specified a strongly typed model like this:
@ModelType IEnumerable(Of MyModel)
But around the same time that I upgraded to 5.2.2, I reorganized my namespaces so that MyModel
was in a different namespace, and this caused the problem. The fix was to change it to this:
@ModelType IEnumerable(Of NewNamespace.MyModel)
It would be nice if the compiler had caught this. It would never have occurred to me that it couldn't find my model object type at all but wouldn't just say so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With