【问题标题】:MVC 5 Bundle ErrorMVC 5 包错误
【发布时间】:2015-03-12 21:33:11
【问题描述】:

我有一个大问题。我创建了一个 MVC 5 项目,但无法使用默认代码启动它。问题在于捆绑。它在 Global.asax.cs/Application_Start 方法的 BundleConfig.RegisterBundles(BundleTable.Bundles); 行中停止。 它说“找不到方法:'!!0 [] System.Array.Empty()'。” (System.MissingMethodException)。

这是BundleConfig.cs 代码(默认):

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"));
        }

我正在使用 VS 2015 预览版。我应该做什么/改变?

谢谢!

【问题讨论】:

标签: asp.net-mvc bundle


【解决方案1】:

正如 Mrchief 在 cmets 中所说,问题出在针对 .NET 4.6 进行编译,但它不是错误:如果您愿意,可以在您的服务器上部署 4.6 RC 运行时。如果您在 Azure 中运行,则此选项可能在 4.6 正式发布(即不是 RC)之前不可用。

来自http://blogs.msdn.com/b/dotnet/archive/2015/05/08/targeting-the-net-framework-4-6-rc.aspx

您的应用需要 .NET Framework 4.6(或更高版本)才能运行。您需要部署.NET Framework 4.6 RC

目前最安全的方法是不要以 4.6 为目标,除非你真的需要它。

【讨论】:

    【解决方案2】:

    如果服务器上未安装 .NET 4.6,则会发生这种情况。如果您有自己的 Web 服务器(不是 Azure),您可以get the installer here。注意 - 不要将目标包与实际的 .NET 安装程序混淆。

    【讨论】:

      猜你喜欢
      • 2015-10-02
      • 2016-10-26
      • 1970-01-01
      • 2017-11-07
      • 2014-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多