Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BC30561: 'Html' is ambiguous, imported from the namespaces or types 'System.Web.WebPages, System.Web.Mvc'

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:

enter image description here

But I'm not sure what to do with this fact.

like image 914
Joshua Frank Avatar asked Sep 25 '14 11:09

Joshua Frank


1 Answers

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.

like image 171
Joshua Frank Avatar answered Oct 17 '22 22:10

Joshua Frank