See CSS File in BundleConfig to Generate WebGrease.dll Error

When I put a specific CSS file called glyphicons.css in my BundleConfig, the following error appears

An exception of type 'System.IndexOutOfRangeException' occurred in WebGrease.dll but was not handled in user code

and the file exists in my solution in a specific way, like all other CSS files.

Has anyone encountered this problem yet?

  bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/css/bootstrap.css", "~/Content/css/uploadfyBoot/style.css", "~/Content/css/uploadfyBoot/jquery.fileupload.css", "~/Content/css/tipografia.css", "~/Content/css/glyphicons.css" )); 

If I remove the link to glyphicons.css, it works.

+7
asp.net-mvc bundle
source share
4 answers

I had the same problem. My project is running using MVC5. I tried updating webGrease using the NuGet package manager and reopened the solution and it worked.

+25
source share

if you are using Visual studio 2013: After adding these new boot files to the content folder, update BundleConfig.cs to reflect your changes.

The next step is important if you are still getting this error.

It is not uncommon that the files downloaded from bootswatch.com are inconsistent with your 2013 project. I fixed my mistake by updating Microsoft ASP.NET MVC and webGrease using Manage NuGet Packages. After you update these two, close and reopen your solution.

+5
source share

I had this problem. My version of webgrease.dll was the latest, so nothing was updated. A closer look at the BundleConfig file showed the following.

  bundles.Add(new ScriptBundle("~/Content/css").Include( "~/Content/css/cssfile1.css", "~/Content/css/cssfile2.css", )); 

When creating my css packages, I accidentally copied a script block of a code package. After that fixed:

 bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/css/cssfile1.css", "~/Content/css/cssfile2.css", )); 

In short, I replaced "ScriptBundle" with "StyleBundle". Now it works fine.

+4
source share

Type this into Nuget's “Install-Package WebGrease” (there wasn’t enough rep to add it to the top answer)

+1
source share

All Articles