I converted a ASP.net 4 webform project to Asp.net MVC4 according to Chapter 13 of the Professional ASP.NET 3.5 MVC, by Scott Hanselmen, Phil Haack, and Rob Conery, Published by Wiley Publishing, Inc. (ISBN: 978-0-470-38461-9). I also followed this blog. Now I can add Controllers, Views, etc. All the references are set properly. No build errors. But upon launching the converted project, I got compilation errors. I have mvc3 installed on the same machine. I even changed the reference to that. It still complain. Could you help? Thanks.
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Source Error:
Line 109: <namespaces>
Line 110: <add namespace="System.Web.Helpers"/>
Line 111: <add namespace="System.Web.Mvc"/>
Line 112: <add namespace="System.Web.Mvc.Ajax"/>
Line 113: <add namespace="System.Web.Mvc.Html"/>
Source File: c:\Users\Jon\Documents\Visual Studio 2012\Projects\CMT\Apps\Branches\3.0\Web.config Line: 111
I had the same problem and I had solved it with:
1.Right click to solution and click 'Clean Solution'
2.Click 'References'
folder in solution explorer and select the problem reference (in your case it seems System.Web.Mvc) and then right click and click 'Properties'
.
3.In the properties window, make sure that the 'Copy Local'
property is set to 'True'
This worked for me. Hope it works for someone else
Helpful Note: As it has mentioned in comments by @Vlad:
If it is already set to True:
This problem can happen when you deploy your web application to a server, so you must check if you already installed MVC3.
Check if the folder C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3
exists.
If it doesn't exist, you need to install it from http://www.microsoft.com/en-us/download/details.aspx?id=1491
If you wont to install you can add all DLLs locally in bin folder and add references to them this work fine if you host on server don't deploy ASP.NET Web Pages or MVC3.
Check your runtime tag inside the web.config, and verify you have something like this declared:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
.....
</runtime>
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