Đôi khi sau khi xây dựng và khởi chạy ứng dụng web MVC4 của tôi, tôi nhận được lỗi này. Nó có thể biến mất sau khi xây dựng lại hay không. Cùng một vấn đề tôi nhận được sau khi xuất bản lên Windows Azure.Không thể tải loại 'System.Web.Optimization.StyleBundle'
Có ai biết cách sửa lỗi này không?
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
UPD: Tôi đã tìm thấy vấn đề.
Có tham chiếu sai đến System.Web.Optimization.dll, trang web của tôi đã cố sử dụng phiên bản cũ. Xóa gói và sau đó thêm lại không giúp mọi lúc.
Giải pháp là: xóa hoàn toàn gói cũ, tham chiếu và cấu hình gói khỏi tất cả các trang web và sau đó thêm lại.
Hy vọng điều này sẽ giúp người khác.
Tôi đã tự tìm thấy vấn đề. Có tham chiếu sai đến System.Web.Optimization.dll, trang web của tôi đã cố sử dụng phiên bản cũ. Xóa gói và sau đó thêm lại không giúp mọi lúc. Giải pháp là: xóa hoàn toàn gói cũ, tham chiếu và cấu hình gói từ tất cả các trang web và sau đó thêm lại. Hy vọng điều này sẽ giúp cho ai đó. –
hãy đặt câu trả lời này làm câu trả lời để câu hỏi này không xuất hiện chưa được trả lời. Chỉ cần đánh dấu câu trả lời của riêng bạn là chính xác –
Vui lòng đánh dấu câu trả lời này là câu trả lời để câu trả lời sẽ không hiển thị trong danh sách chưa được trả lời. – SoftSan