System.Web.Optimization and Microsoft.Web.Optimization won't load reference in vs 2012

前端 未结 12 1289
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 01:46

I\'m working on an MVC 4 project started in Visual Studio 2010. Right now I\'m working on a machine with Visual Studio 2012 as I don\'t have access to the machine I was original

相关标签:
12条回答
  • 2021-02-05 02:20

    This is a long shot but here it goes anyway, right click on the project --> Property Pages and make sure System.Web.Optimization entry exists. If not, copy the System.Web.Optimization.dll to your bin folder or import it as a reference.

    Edit: mvc projects don't have the "Property pages" menu option.

    One other thing you can try is create a new mvc4 basic project, go to the bin folder of the solution and copy the System.Web.Optimization.dll to the bin folder of your other project that is giving you the error. If you can't find the dll then try updating the nuget packages.

    0 讨论(0)
  • 2021-02-05 02:21

    I know it's confusing, but you will need to Install-Package Microsoft.AspNet.Web.Optimization

    0 讨论(0)
  • 2021-02-05 02:21

    What worked for me in a specific scenario (I downloaded a MVC project from source control and received that error), was to open a new MVC project on the same solution. Afterwards I could delete the new project I've created and it still works (on VS2012).

    0 讨论(0)
  • 2021-02-05 02:23

    I battled this for an hour and none of the above suggestions worked. In the end only the following worked (for some obtuse reason) :

    1. ctrl-q -> type "package manager console"
    2. Uninstall-Package Microsoft.AspNet.Web.Optimization <problem project name>
    3. Install-Package Microsoft.AspNet.Web.Optimization <problem project name>

    WARNING/HEADS-UP

    • the above will install the latest version of Microsoft.AspNet.Web.Optimization. If you want a particular version (say v1.1.1), use Install-Package Microsoft.AspNet.Web.Optimization <problem project name> -Version 1.1.1
    • don't forget the <problem project name> parameter or nuget will operate at the Solution-level, possibly trampling sibling projects.
    • Note that omitting the project name is an of itself really handy for doing Solution-level version updates or package installs.
    0 讨论(0)
  • Go to tools >> Library Package Manager >> Manage Nuget Packages >> install Microsoft ASP.NET web optimisation framework

    0 讨论(0)
  • 2021-02-05 02:30

    Reinstalling system.web.optimizaiton using Nuget package manager solved this issue for me..

    0 讨论(0)
提交回复
热议问题