After converting a Hybrid ASP.NET MVC1 app to MVC2 I'm getting the following error when I try and run the application:
The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
The allegeded culprit in the web.config file is System.Web.Mvc:
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
So far my investigation seems to lead me to believe that version 2 of System.Web.Mvc is not installed or has not been picked up.
I've tried creating a File > New Project based on MVC 2 and that's picking up the new (v2) version of MVC. I've also converted some other projects (that were not hybrids) and they've converted without problem to MVC2.
I've also uninstalled MVC1 to try and remove references to it from the GAC. However, none of this has worked.
Any ideas?
Make sure you have the binding redirect in your Web.config:
This forces MVC 2 even if MVC 1 is on the machine.
Also: MVC 1 does have a
System.Web.Mvc
namespace, so make sure you also have:I came across somthing similar and the solution was to change the reference to Microsoft.Web.Mvc so Copy Local was set to True.
I had the same error and clicking the detailed compilation error link in the page showed problems with
System.Web.Helpers
,.Http,
and.WebPages
.After backing up the system I ran
update-package -reinstall
' and forced an uninstall/reinstall of all packages. This forced the web.config file to be rebuilt correctly and thedependentAssembly
sections were constructed right.After rebuilding the solution it ran first time.
Note, it did add the following bad
providers
section to the web.config.This only generates a build warning, but I did remove it in favor of the preceeding
contexts
element.