none
Why does removing the unused WebGrease cause my WebAPI app to fail? RRS feed

  • Question


  • I selected the References > Remove Unused References context menu item in my WebAPI app.

    Now, though (WebGrease was one of the references removed), I get this in Visual Studio:

        System.IO.FileNotFoundException was unhandled by user code
          HResult=-2147024894
          Message=Could not load file or assembly 'WebGrease, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
          Source=System.Web.Optimization
          FileName=WebGrease, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
            . . .

    ...and this in the browser:

        Server Error in '/' Application.
        
        Could not load file or assembly 'WebGrease, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
        
        Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
        
        Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'WebGrease, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
        
        Source Error: 
        
        
        Line 5:      <meta name="viewport" content="width=device-width" />
        Line 6:      <title>@ViewBag.Title</title>
        Line 7:      @Styles.Render("~/Content/css")
        Line 8:      @Scripts.Render("~/bundles/modernizr")
        Line 9:  </head>
        
        Source File: c:\HHS_Server_WebAPI\HHSServerWebAPI\HHSServerWebAPI\Views\Shared\_Layout.cshtml    Line: 7 
        
    Do I need to add back WebGrease, or is there another workaround?
    • Moved by Amanda Zhu Monday, October 14, 2013 6:37 AM
    Friday, October 11, 2013 6:19 PM

All replies

  • I added it back via NuGet and, after a restart of VS2013, it works again, but I still wonder why WebGrease is both unneeded and needed.
    Friday, October 11, 2013 6:33 PM
  • Hello,

    Thank you for your post.

    I am afraid that the issue is out of support range of VS General Question forum which mainly discusses WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System and Visual Studio Editor.

    Since the issue occurs at ASP.NET Web app, I suggest that you can consult your issue on ASP.NET forum: http://forums.asp.net/  for better solution and support.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 14, 2013 6:37 AM