locked
Missing Connection to BundleConfig! RRS feed

  • Question

  • User1421620300 posted

    I have a problem with my app. This is a attempt at conversion from regular HTML web forms to using  a template so that i can use bootstrap in my new application! I wanted to see if it would be possible to use a new project webforms template with master pages to use bootstrap. So after starting the new app what i did was imported all of my webform pages from the old application all all required files. database, webconfig, settings etc. And then tried to rebuild the newer app with the original files. But the newer application did not compile for some reason or another. The error that i receive is in the BundleConfig file class.   I have tried the solutions to solve issue which are to update reference for whatever package is looking for, but i have updated all of my packages.  Allthough i still receive as my first error is the type or namespace Optimization does not exist. Now i only receive the following errors as seen below. Please help, Thanks. markus33

    Severity Code Description Project File Line Suppression State
    Error CS0234 The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - Copy_2 V:\WEBCIS407A_W3_iLab_Test_Working - Copy_2 - Copy\App_Start\BundleConfig.cs 2 Active
    Error CS0246 The type or namespace name 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - Copy_2 V:\WEBCIS407A_W3_iLab_Test_Working - Copy_2 - Copy\App_Start\BundleConfig.cs 9 Active
    Error CS0246 The type or namespace name 'ScriptBundle' could not be found (are you missing a using directive or an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - 
    Error Could not install package 'Microsoft.Web.Infrastructure 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    Errors in Bold:

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

    namespace WEBCIS407A_W3_iLab_Test_Working
    {
    public class BundleConfig
    {
    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
    "~/Scripts/jquery-{version}.js"));

    bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
    "~/Scripts/jquery.validate*"));

    // Use the development version of Modernizr to develop with and learn from. Then, when you're
    // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
    bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
    "~/Scripts/modernizr-*"));

    bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
    "~/Scripts/bootstrap.js",
    "~/Scripts/respond.js"));

    bundles.Add(new StyleBundle("~/Content/css").Include(
    "~/Content/bootstrap.css",
    "~/Content/site.css"));
    }
    }
    }

    Sunday, November 3, 2019 8:11 AM

Answers

  • User-719153870 posted

    Hi Markus33,

    Markus33

    Error CS0234 The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - Copy_2 V:\WEBCIS407A_W3_iLab_Test_Working - Copy_2 - Copy\App_Start\BundleConfig.cs 2 Active
    Error CS0246 The type or namespace name 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - Copy_2 V:\WEBCIS407A_W3_iLab_Test_Working - Copy_2 - Copy\App_Start\BundleConfig.cs 9 Active
    Error CS0246 The type or namespace name 'ScriptBundle' could not be found (are you missing a using directive or an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - 

    These three errors are all caused by the lost reference of System.Web.Optimization.

    Please check your web.config file see if there the reference in it, like below in my web.config file:

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.8" />
        <httpRuntime targetFramework="4.8" />
        <pages>
          <namespaces>
            <add namespace="System.Web.Optimization" />
          </namespaces>
          <controls>
            <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
          </controls>
        </pages>
      </system.web>

    To solve these issues, please run below command in your package manager console( Tools - Nuget Package Manager - Package Manager Console):

    Install-Package Microsoft.AspNet.Web.Optimization

    You can refer to these threads: BundleCollectionOptimization and ScriptBundle.

    Markus33

    Error Could not install package 'Microsoft.Web.Infrastructure 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    This is also a package related issue, you can try update your project target framework or clear the data in Nuget packages (Before you are going to try the second method, please make sure you have back up all related files).

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 4, 2019 5:26 AM

All replies

  • User-719153870 posted

    Hi Markus33,

    Markus33

    Error CS0234 The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - Copy_2 V:\WEBCIS407A_W3_iLab_Test_Working - Copy_2 - Copy\App_Start\BundleConfig.cs 2 Active
    Error CS0246 The type or namespace name 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - Copy_2 V:\WEBCIS407A_W3_iLab_Test_Working - Copy_2 - Copy\App_Start\BundleConfig.cs 9 Active
    Error CS0246 The type or namespace name 'ScriptBundle' could not be found (are you missing a using directive or an assembly reference?) WEBCIS407A_W3_iLab_Test_Working - 

    These three errors are all caused by the lost reference of System.Web.Optimization.

    Please check your web.config file see if there the reference in it, like below in my web.config file:

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.8" />
        <httpRuntime targetFramework="4.8" />
        <pages>
          <namespaces>
            <add namespace="System.Web.Optimization" />
          </namespaces>
          <controls>
            <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
          </controls>
        </pages>
      </system.web>

    To solve these issues, please run below command in your package manager console( Tools - Nuget Package Manager - Package Manager Console):

    Install-Package Microsoft.AspNet.Web.Optimization

    You can refer to these threads: BundleCollectionOptimization and ScriptBundle.

    Markus33

    Error Could not install package 'Microsoft.Web.Infrastructure 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    This is also a package related issue, you can try update your project target framework or clear the data in Nuget packages (Before you are going to try the second method, please make sure you have back up all related files).

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 4, 2019 5:26 AM
  • User1421620300 posted

    Hello Yang. I was able to correct issue with project by either updating the Framework target, or the Installation of the Optimization package. One of these works for me! Thanks, Markus

    Saturday, November 16, 2019 3:12 PM