5
using System.Web;
using System.Web.Optimization;

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*"));

我收到错误消息:

Error   16  The type or namespace name 'ScriptBundle' could not be found (are you missing a using directive or an assembly reference?)

看起来像一些参考问题,但我无法弄清楚。请帮忙。什么可能导致此错误?

4

3 回答 3

12
Install-Package Microsoft.AspNet.Web.Optimization
于 2013-07-15T10:29:30.627 回答
1

将 MVC3 项目升级到 MVC4 时出现此错误。我缺少对 NuGet 包 Microsoft ASP.NET Web 优化框架 (Microsoft.AspNet.Web.Optimization) 中的 System.Web.Optimization.dll 的引用。

于 2013-06-13T00:09:35.410 回答
0

我有同样的问题。这是解决方案How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app

于 2013-07-16T00:43:00.683 回答