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

Flame_Phoenix

So, I have a MVC 4 project in C# and I am using Visual Studio For Web 2012 Express.

I cannot compile the projecto due to the error: The type or namespace name 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?)

Normally, this would mean that a library is missing. Thus after making a quick search on the internet I used NuGet to install Microsoft.AspNet.Web.Optimization, but that still did not work.

What makes this intriguing to me is that BundleCollections should be known to the application by deafult. I can only imagine that I have added a dependency that messed everything up, but I really can't know for sure.

How can I fix this problem? What am I missing here?

Code:

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

namespace Dockis
{

    public class BundleConfig
    {
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            IItemTransform cssFixer = new CssRewriteUrlTransform();

            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

           //...
        }
    }
}

EDIT

After checking my references folder I tried running the command Install-Package System.Web.Optimization, however I cannot install this package. I get the following error:

Install-Package : One or more errors occurred.
At line:1 char:16
+ Install-Package <<<<  System.Web.Optimization
    + CategoryInfo          : NotSpecified: (:) [Install-Package], AggregateException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

What is odd, is the fact that running Install-Package System.Web.Optimization.Less works, and fixes some depencie problems, but not all of them. Thus I believe I really need the first command to work.

What am I doing wrong?

Flame_Phoenix

There is no clear answer for this question. I managed to fix the project only by re-creating it, and then downloading all the DLLs in a different order, closing and re-opening the visual studio several times while doing it.

Aparently there was some conflict between some of the packages, but that was impossible to guess until I had re-created the project from scratch again.

Running Install-Package Microsoft.AspNet.Web.Optimization did solve the problem after the clean install however, so I recommend it.

I thank everyone for the help.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Unity 2019 error The type or namespace name 'NotSupportedException' could not be found (are you missing a using directive or an assembly reference?)

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

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

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

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

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

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

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

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

The type or namespace name Edm could not be found are you missing a using directive or an assembly reference

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

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

Blazor the type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)

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

How to resolve "The type or namespace name 'Didstopia' could not be found (are you missing a using directive or an assembly reference?)"

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

Getting error The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)

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

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

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

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

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

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

error CS0246: The type or namespace name 'LoadSceneMode' could not be found (are you missing a using directive or an assembly reference?)

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

The type or namespace name ‘player’ could not be found. (Are you missing a directive or an assembly reference)

CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference? in c#

CS0246 C# The type or namespace name 'ForeignKeyAttribute' could not be found (are you missing a using directive or an assembly reference?)

How to solve CS0246 The type or namespace name 'TypeNameSerializer' could not be found (are you missing a using directive or an assembly reference?