简体   繁体   中英

Visual Studio 2015 enable MVC 4 support

I have an ASP.NET MVC 4 project that "works on my machine(old)". When I load a project in a fresh installation of VS 2015(on a new laptop) - a lot of assemblies are missing and when I try to build the project it complains that classes like ActionResult, Controller are missing.

I checked that on the old laptop the missing dependencies are coming from C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies . On the new laptop I have only the xml descriptors of the packages but not the dlls.

What I have to install to use MVC 4 in Visual Studio 2015?

Edit: missing dependencies are:

  • System.Web.Helpers
  • System.Web.Mvc
  • System.Web.WebPages
  • System.Web.WebPages.Deployment
  • System.Web.WebPages.Razor

I Recommend getting them again from Nuget for your ActionResult Issue its Microsoft.AspNet.Mvc which is making issue.

Open Package Manager Console and insert the command below:

Install-Package Microsoft.AspNet.Mvc

Nuget has this feature that allows you to restore all the missing Assemblies which exists in nuget. you can try that out as well.

Anyway for the rest of them install these packages below as well:

  • Install-Package Microsoft.AspNet.WebHelpers
  • Install-Package Microsoft.AspNet.WebPages
  • Install-Package Microsoft.AspNet.Razor

Check if you have install update 3 for VS2015

also check if Microsoft web developer tools are installed correctly

在此处输入图片说明

I have had the same issues when using source control or moving projects from one PC to another.

There is a work around that I use quite often and it works.

  1. Go to YourProjectFolder -> packages. Remove all the folders except for the xml, repositories.xml, file which is the xml config file for packages downloaded from Nuget.

  2. On your solution in Visual Studio Right click and select Enable Nuget Packages Restore.

  3. Then build the application it will re-download all the required packages. Hope this helps

For Me what solved the issue is to install ASP.NET MVC 4 for Visual Studio 2010 from Microsoft Web Page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM