gpt4 book ai didi

asp.net-mvc - 使用 Microsoft ASP.NET Web 优化框架的 MVC4-RC (.net 4.0) 中出现错误

转载 作者:行者123 更新时间:2023-12-02 01:00:23 26 4
gpt4 key购买 nike

我正在使用最新的 MVC4-RC (.net 4.0) 和 Microsoft ASP.NET Web Optimization Framework http://nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0-beta3我收到这个错误。

Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.

[MissingMethodException: Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.] App.MVC.BundleConfig.RegisterBundles(BundleCollection bundles) in C:...\App_Start\BundleConfig.cs:53 App.MVC.MvcApplication.Application_Start() in C:...\Global.asax.cs:47

[HttpException (0x80004005): Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +4057141 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +191 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375

[HttpException (0x80004005): Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869125

这是我正在使用的代码:

在global.asax.cs中

protected void Application_Start()
{
...
BundleConfig.RegisterBundles(BundleTable.Bundles);
...

然后在App_Start/BundleConfig.cs中

using System.Web.Optimization;

namespace App.MVC.App_Start
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new Bundle("~/scripts/packed.js", new JsMinify()).Include(
// jquery
"~/Scripts/jquery-1.7.1.js",
"~/Scripts/jquery-ui-1.8.17.js",
"~/Scripts/jquery.validate.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery.unobtrusive-ajax.js"));

bundles.Add(new Bundle("~/content/css/packed.css", new CssMinify()).Include(
// reset
"~/Content/css/cssreset-min.css",
"~/Content/css/cssfonts-min.css",

// themes
"~/Content/themes/base/jquery-ui-1.8.16.custom.css",

// site
"~/Content/css/Site.css"));
}
}
}

我还在这个项目中使用 Azure,有趣的是,当我第一次启动 Azure 时,我收到此错误。然后当我重建 MVC 项目并刷新页面时,它就可以工作了。

我该如何解决这个问题?

最佳答案

当我引用错误的包时,我收到了同样的错误通过

  Install-Package Microsoft.Web.Optimization -Version 1.0.0-beta -Pre

通过引用正确的较新包解决

Install-Package Microsoft.Web.Optimization -Pre 

关于asp.net-mvc - 使用 Microsoft ASP.NET Web 优化框架的 MVC4-RC (.net 4.0) 中出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11127264/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com