asp.net-mvc - MVC 5 bundle 错误

标签 asp.net-mvc bundle

我有一个大问题。我创建了一个 MVC 5 项目,但无法使用默认代码启动它。问题出在 bundle 上。它停止在 Global.asax.cs/Application_Start 方法的 BundleConfig.RegisterBundles(BundleTable.Bundles); 行上。 它显示“找不到方法:'!!0[] System.Array.Empty()'。” (系统.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 预览版。我应该做什么/改变什么?

谢谢!

最佳答案

正如 Mrchief 在评论中所说,问题是由于针对 .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 :

your app will require the .NET Framework 4.6 (or later) to run. You will need to deploy the .NET Framework 4.6 RC

目前最安全的做法是不要以 4.6 为目标,除非您确实需要它。

关于asp.net-mvc - MVC 5 bundle 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29020614/

相关文章:

ruby-on-rails - bundle 安装错误 "invalid byte sequence in US-ASCII (ArgumentError)"

javascript - 如何为任何给定的库编写 Bundle.CdnFallbackExpression?

.net - GNU/Linux 上的 dotnet bundle 后 css 中的路径错误

c# - 具有键 'CategoryId' 的 ViewData 项的类型为 'System.Int32' 但必须为 'IEnumerable<SelectListItem>' 类型?

asp.net-mvc - MVC5 Html.RenderAction 与不同的 Controller

android - 如何将对象数组传递给 Activity?

android - 如何检查 Activity 是否与元数据标签关联?

iphone - 如何创建 bundle

asp.net-mvc - 如何在未经授权的情况下重定向到登录屏幕,同时在 MVC 中返回 401 状态代码?

asp.net - 在没有 System.Web 的 DNX 5 中使用 [Bind(排除 ='ID')]