asp.net-mvc-3 - 无法加载文件或程序集“System.Web.WebPages.Razor,版本=2.0.0.0”

标签 asp.net-mvc-3 razor dependencies asp.net-4.0

我刚刚升级了 MVC 3 项目 (ASP.net 4) 中的包,现在访问该项目中的页面时收到以下错误消息:

Server Error in '/MyApplication' Application.

Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 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.IO.FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

=== Pre-bind state information === LOG: User = IIS APPPOOL\ASP.NET v4.0 LOG: DisplayName = System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (Fully-specified) LOG: Appbase = file:///C:/.../ LOG: Initial PrivatePath = C:...\bin Calling assembly : Microsoft.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:...\web.config LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/.../cb62a7b2/327a0353/System.Web.WebPages.Razor.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/.../cb62a7b2/327a0353/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL. LOG: Attempting download of new URL file:///C:/LeGroupeHtmSVN/.../UpDir.Web/bin/System.Web.WebPages.Razor.DLL. WRN: Comparing the assembly name resulted in the mismatch: Major Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
Microsoft.Web.Helpers.PreApplicationStartCode.Start() +0

[InvalidOperationException: The pre-application start initialization method Start on type Microsoft.Web.Helpers.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +11711966
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +465
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167

[HttpException (0x80004005): The pre-application start initialization method Start on type Microsoft.Web.Helpers.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869125

-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

在我的 web.config 文件和应用程序中,我引用 System.Web.WebPages.Razor v1.0.0.0:

  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
  </dependentAssembly>

我什至不知道是否可以将 System.Web.WebPages.Razor v2.0.0.0 与 .Net 4 一起使用。

现在,我如何找出引用 System.Web.WebPages.Razor v2.0.0.0 的内容?

最佳答案

就这么简单。在 Nuget 包管理器控制台中:

更新包 Microsoft.AspNet.Mvc - 重新安装

关于asp.net-mvc-3 - 无法加载文件或程序集“System.Web.WebPages.Razor,版本=2.0.0.0”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11000506/

相关文章:

c# - 如何将 LINQ to SQL Distinct() 运算符应用于 List<T>?

asp.net-mvc - ASP.NET MVC 3 url 路由

c# - NinjectMVC3 的 WebActivator.PreApplicationStartMethod 程序集属性在我的 View 源代码编辑器中导致警告

java - Maven - 在依赖项中使用版本

angularjs - 如何使用angularjs和MVC3以相同的功能从两个不同的html文件上传中保存两个文件

asp.net-mvc-3 - 使用 NAnt 构建 ASP.NET MVC 3 时出现 System.Web.Mvc 丢失错误

asp.net-mvc - Href ASP.NET MVC/Razor 的 URL 编码字符串

css - 如何更改 Razor View 中第一个字母的颜色?

compilation - 构建依赖和运行时依赖有什么区别

maven - 创建一个maven项目模块树?