无法加载文件或程序集“System.Web.Razor”或其依赖项之一

2024-05-22

我在我的网站(Web 应用程序)中使用了 Umbraco 4.11.6。我的网站在 localhost 中工作(通过 Visual Studio 2012 和 IIS(v7) 进行测试),但是当我从互联网空间运行它时,出现错误。 错误是:

无法加载文件或程序集“System.Web.Razor”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)

程序集加载跟踪:以下信息有助于确定程序集“System.Web.Razor”无法加载的原因。

WRN:程序集绑定日志记录已关闭。 要启用程序集绑定失败日志记录,请将注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) 设置为 1。 注意:程序集绑定失败日志记录会带来一些性能损失。 要关闭此功能,请删除注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog]。

堆栈跟踪:

[FileLoadException:无法加载文件或程序集“System.Web.Razor”或其依赖项之一。所在的程序集 清单定义与程序集引用不匹配。 (例外 来自 HRESULT:0x80131040)]

[FileLoadException:无法加载文件或程序集“System.Web.Razor, 版本=2.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35' 或 它的依赖项之一。找到的程序集的清单定义 与装配参考不匹配。 (HRESULT 的异常: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名、字符串代码库、证据程序集安全性、运行时程序集 locationHint、StackCrawlMark& stackMark、IntPtr pPrivHostBinder、 布尔型 throwOnFileNotFound、布尔型内省、布尔型 抑制安全检查)+0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef、证据 assemblySecurity、RuntimeAssembly reqAssembly、 StackCrawlMark& stackMark、IntPtr pPrivHostBinder、布尔值 throwOnFileNotFound,布尔值用于内省,布尔值 抑制安全检查)+210
System.Reflection.RuntimeAssembly.InternalLoad(字符串 assemblyString, 证据组装Security、StackCrawlMark& stackMark、IntPtr pPrivHostBinder,用于自省的布尔值)+242
System.Reflection.RuntimeAssembly.InternalLoad(字符串 assemblyString, 证据组装Security、StackCrawlMark& stackMark、Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String 汇编字符串)+35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName,布尔星指令)+122

[ConfigurationErrorsException:无法加载文件或程序集 'System.Web.Razor,版本=2.0.0.0,文化=中性, PublicKeyToken=31bf3856ad364e35' 或其依赖项之一。这 找到的程序集的清单定义与程序集不匹配 参考。 (HRESULT 异常:0x80131040)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName,布尔星指令)+12761078
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection 补偿配置)+334
System.Web.Compilation.BuildManager.CallPreStartInitMethods(字符串 预启动初始化列表路径)+203
System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager 应用程序管理器、IApplicationHost 应用程序主机、IConfigMapPathFactory configMapPathFactory、 HostingEnvironmentParameters 托管参数、 策略级别策略级别,异常appDomainCreationException)+1151

[HttpException (0x80004005): 无法加载文件或程序集 'System.Web.Razor,版本=2.0.0.0,文化=中性, PublicKeyToken=31bf3856ad364e35' 或其依赖项之一。这 找到的程序集的清单定义与程序集不匹配 参考。 (HRESULT 异常:0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+12881540 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext 上下文)+12722601

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.17929

Web 配置的一部分:

<runtime>
<!-- Old asp.net ajax assembly bindings -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

有很多方法可以解决这个问题:

  1. 在 Web 服务器上安装 MVC(这并不总是可行)。

  2. 在 Visual Studio 中,您可以将 dll 设置为在构建时复制到本地,请参阅以下文章(请注意,MVC dll 的名称略有更改,但它为您提供了过程)http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx

  3. 将适当的 dll 从 GAC 复制到 umbraco 站点的 bin 文件夹中。 为此,请在资源管理器中打开“%windir%\ Microsoft.NET \ assembly \ GAC_MSIL”,您将找到GAC中安装的所有dll,您可以将适当的版本复制到您的项目中。这与上面的方法类似,但绕过了构建项目。

就文件而言,您可能需要的不仅仅是 System.Web.Razor.dll,但这适用于所有丢失的文件。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法加载文件或程序集“System.Web.Razor”或其依赖项之一 的相关文章

随机推荐