asp.net - 无法加载类型 'System.Web.Optimization.StyleBundle'

标签 asp.net asp.net-mvc

有时在构建并启动我的 MVC4 Web 应用程序后,我会收到此错误。 重建后它可能会消失,也可能不消失。 发布到 Windows Azure 后我遇到了同样的问题。

有人知道如何解决这个错误吗?

Server Error in '/' Application.

Could not load type 'System.Web.Optimization.StyleBundle' from assembly 'System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

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.TypeLoadException: Could not load type 'System.Web.Optimization.StyleBundle' from assembly 'System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 
[TypeLoadException: Could not load type 'System.Web.Optimization.StyleBundle' from assembly 'System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
   Inventarium.Web.Mobile.App.BundleConfig.RegisterBundles(BundleCollection bundles) in c:\dev\Inventarium\Inventarium.Web\Inventarium.Web.Mobile.App\App_Start\BundleConfig.cs:30
   Inventarium.Web.Mobile.App.MvcApplication.Application_Start() in c:\dev\Inventarium\Inventarium.Web\Inventarium.Web.Mobile.App\Global.asax.cs:18

[HttpException (0x80004005): Could not load type 'System.Web.Optimization.StyleBundle' from assembly 'System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +4058245
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): Could not load type 'System.Web.Optimization.StyleBundle' from assembly 'System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
 System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11703488
 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4870277

最佳答案

根据罗马尼基丁评论:

我自己发现了问题。对 System.Web.Optimization.dll 的引用错误,我的网站尝试使用旧版本。删除包然后重新添加并非每次都有帮助。

解决方案是:从所有网站中完全删除旧的包、引用和包配置,然后重新添加。

关于asp.net - 无法加载类型 'System.Web.Optimization.StyleBundle',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11552898/

相关文章:

C# 随机数命中率远超预期

c# - _Default 关键字在 C# 中意味着什么

c# - 无法在 NLB 上加载 View 状态

javascript - ajax发送二维数组到操作方法错误 - asp.net mvc

asp.net - 在 asp :hyperlink. 中分配声明性值时出现问题错误 : this is not scriptlet. 将输出为纯文本

javascript - Visual Studio 显示错误

mysql - MySQL 的 ASP.NET 成员资格/角色提供程序?

c# - 如果错误已经逐字段显示,如何不显示 ASP MVC ValidationSummary?

css - 如何限制我在 Zurb 基金会的 Web 应用程序中的移动 View ?

asp.net-mvc - .NET MVC : Calling RedirectToAction passing a model?