我正在做一个在Visual 2010中启动的MVC 4项目。现在,我正在使用Visual 2012开发一台机器,因为我无法访问我最初使用的机器。我整个上午都在寻找答案,但它们似乎无助于我的处境。
我跟踪How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app并从nuget安装到我的解决方案中。尽管我已经下载了所有必需的参考包并在我的机器上安装,但System.Web.Optimization仍然没有找到。还有什么我能做的吗?
编辑:当我试图构建项目时,我会收到以下错误
我的BundleConfig.cs包含
using System.Web;
using System.Web.Optimization;
namespace BCCDC_AdminTool
{
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/? LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.slider.css",
"~/Content/themes/base/jquery.ui.tabs.css",
"~/Content/themes/base/jquery.ui.datepicker.css",
"~/Content/themes/base/jquery.ui.progressbar.css",
"~/Content/themes/base/jquery.ui.theme.css"));
}
}
}发布于 2013-04-23 21:52:22
这是一个很长的机会,但无论如何,右键单击项目->属性页,并确保System.Web.Optimization条目存在。如果没有,请将System.Web.Optimization.dll复制到bin文件夹或作为引用导入它。
编辑: mvc项目没有“属性页面”菜单选项。
您可以尝试的另一件事是创建一个新的mvc4基本项目,转到解决方案的bin文件夹,并将System.Web.Optimization.dll复制到给您提供错误的另一个项目的bin文件夹。如果找不到dll,那么尝试更新nuget包。
发布于 2013-07-22 13:01:08
我在VS2012中打开的一个VS2012项目也遇到了同样的问题。Microsoft.AspNet.Web.Optimization包丢失了,所以我只需要使用Nuget下载它。
您可以在控制台中运行:Install-Package Microsoft.AspNet.Web.Optimization
发布于 2013-07-01 09:08:14
我知道这很让人困惑,但是你需要Install-Package Microsoft.AspNet.Web.Optimization
https://stackoverflow.com/questions/16179293
复制相似问题