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

I am getting the error:

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

Looks like some reference issue, but i am not able to figure it out. Please help. What could be causing this error?

Piccolo
  • 1,612
  • 4
  • 22
  • 38
Vijay Pote
  • 103
  • 1
  • 1
  • 7
  • [This](http://stackoverflow.com/questions/9475893/how-to-add-reference-to-system-web-optimization-for-mvc-3-converted-to-4-app) may give a hint, you need to reference `System.Web.Optimization.dll`. – Joachim Isaksson May 28 '13 at 03:36
  • 1
    Thanks Joachim, but it already has that reference using System.Web.Optimization. May be looks like i will have to uninstall the reference and it back again. – Vijay Pote May 28 '13 at 04:07
  • I had the similar issue [This][1] resolved it. [1]: http://stackoverflow.com/questions/9475893/how-to-add-reference-to-system-web-optimization-for-mvc-3-converted-to-4-app – yantaq Jul 16 '13 at 00:31

3 Answers3

13
Install-Package Microsoft.AspNet.Web.Optimization
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
Fernando Vezzali
  • 2,219
  • 1
  • 29
  • 32
1

I got this error when I was upgrading an MVC3 project to MVC4. I was missing the reference to System.Web.Optimization.dll which is in the NuGet package Microsoft ASP.NET Web Optimization Framework (Microsoft.AspNet.Web.Optimization).

Brian
  • 37,399
  • 24
  • 94
  • 109
0

I had the same problem. here is the solution
How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app.

Community
  • 1
  • 1
yantaq
  • 3,968
  • 2
  • 33
  • 34