System.Web.Optimization和Microsoft.Web.Optimization不会加载在VS 2012的参考 [英] System.Web.Optimization and Microsoft.Web.Optimization won't load reference in vs 2012

查看:674
本文介绍了System.Web.Optimization和Microsoft.Web.Optimization不会加载在VS 2012的参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2010现在我正在一台机器上使用Visual Studio 2012

我工作的一个MVC 4项目启动,因为我没有访问我原本是工作的机器。我整个上午都在试图找到答案,但他们似乎并没有帮助我的情况。

我也跟着<一个href=\"http://stackoverflow.com/questions/9475893/how-to-add-reference-to-system-web-optimization-for-mvc-3-converted-to-4-app\">How添加引用System.Web.Optimization对MVC-3转换到4应用和安装了的NuGet直接进入我的解决方案。即使我拥有所有必需的参考软件包下载并安装到我的机器上, System.Web.Optimization 继续保持下落不明。还有什么我能做什么?

编辑:当我尝试建立我收到以下错误项目


  • 类型或命名空间名称'优化'不会在命名空间System.Web程序存在(是否缺少程序集引用?) - BundleConfig.cs

  • 类型或命名空间名称'优化'不会在命名空间System.Web程序存在(是否缺少程序集引用?) - 的Global.asax.cs

  • 类型或命名空间BundleCollection'找不到(是否缺少using指令或程序集引用?) - BundleConfig.cs

我BundleConfig.cs包含

 使用的System.Web;
使用System.Web.Optimization;命名空间BCCDC_AdminTool
{
    公共类BundleConfig
    {
     //关于捆绑的更多信息,请访问http://go.microsoft.com/fwlink/? LINKID = 254725
    公共静态无效RegisterBundles(BundleCollection包)
    {
           bundles.Add(新ScriptBundle(〜/包/ jQuery的)。包括(
                    〜/脚本/ jquery- {}版本的.js));           bundles.Add(新ScriptBundle(〜/包/ jQueryUI的)。包括(
                    〜/脚本/ jQuery的 - 用户界面 - {}版本的.js));            bundles.Add(新ScriptBundle(〜/包/ jqueryval)。包括(
                    〜/脚本/ jquery.unobtrusive *,
                    〜/脚本/ jquery.validate *));        //使用Modernizr的开发版本,开发和借鉴。然后,当你
        //为生产做好准备,在使用的http://modernizr.com构建工具挑选您所需要的测试。
            bundles.Add(新ScriptBundle(〜/包/ Modernizr的)。包括(
                    〜/脚本/ modernizr- *));            bundles.Add(新StyleBundle(〜/内容/ CSS),包括(〜/内容/的site.css));            bundles.Add(新StyleBundle(〜/内容/主题/基/ CSS)。包括(
                    〜/内容/主题/基/ jquery.ui.core.css
                    〜/内容/主题/基/ jquery.ui.resizable.css
                    〜/内容/主题/基/ jquery.ui.selectable.css
                    〜/内容/主题/基/ jquery.ui.accordion.css
                    〜/内容/主题/基/ jquery.ui.autocomplete.css
                    〜/内容/主题/基/ jquery.ui.button.css
                    〜/内容/主题/基/ jquery.ui.dialog.css
                    〜/内容/主题/基/ jquery.ui.slider.css
                    〜/内容/主题/基/ jquery.ui.tabs.css
                    〜/内容/主题/基/ jquery.ui.datepicker.css
                    〜/内容/主题/基/ jquery.ui.progressbar.css
                    〜/内容/主题/基/ jquery.ui.theme.css));
        }
    }
}


解决方案

这是一个长镜头,但在这里不言而喻反正右键单击项目 - >属性页,并确保System.Web.Optimization条目存在。如果没有,System.Web.Optimization.dll复制到您的bin文件夹或导入它作为参考。

编辑:MVC项目不具备的属性页菜单选项

您可以尝试是创建一个新的mvc4基础工程,去解决方案的bin文件夹并复制System.Web.Optimization.dll到是给你的错误你的其他项目的bin文件夹中的另一件事。如果无法找到DLL,然后尝试更新的NuGet包。

I'm working on an MVC 4 project started in Visual Studio 2010. Right now I'm working on a machine with Visual Studio 2012 as I don't have access to the machine I was originally working on. I tried all morning to find answers, but they don't seem to help my situation.

I followed How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app and installed from nuget right into my solution. Even though I have all the required reference packages downloaded and installed on my machine, System.Web.Optimization continues to remain missing. Is there anything else I can do?

Edit: When I try to build the project I receive the following errors

  • The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) - BundleConfig.cs
  • The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) - Global.asax.cs
  • The type or namespace 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?) - BundleConfig.cs

My BundleConfig.cs contains

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

namespace BCCDC_AdminTool
{
    public class BundleConfig
    {
     // For more information on Bundling, visit http://go.microsoft.com/fwlink/?    LinkId=254725
    public static void RegisterBundles(BundleCollection bundles)
    {
           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*"));

        // 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 StyleBundle("~/Content/css").Include("~/Content/site.css"));

            bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));
        }
    }
}

解决方案

This is a long shot but here it goes anyway, right click on the project --> Property Pages and make sure System.Web.Optimization entry exists. If not, copy the System.Web.Optimization.dll to your bin folder or import it as a reference.

Edit: mvc projects don't have the "Property pages" menu option.

One other thing you can try is create a new mvc4 basic project, go to the bin folder of the solution and copy the System.Web.Optimization.dll to the bin folder of your other project that is giving you the error. If you can't find the dll then try updating the nuget packages.

这篇关于System.Web.Optimization和Microsoft.Web.Optimization不会加载在VS 2012的参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆