gpt4 book ai didi

.net - DotNetOpenAuth 导致无法加载程序集 System.Web.WebPages.Razor

转载 作者:行者123 更新时间:2023-12-02 04:46:14 25 4
gpt4 key购买 nike

我的代码的本地版本运行得很好。但是当我进行网络部署时,出现以下异常:

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)

相关的堆栈跟踪行是

[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.WebPages.OAuth.PreApplicationStartCode.Start() +0

这似乎与 Razor 的 Nuget 包是 3.0 版但 DotNetOpenAuth 包使用 2.0 版有关

此外,该问题仅在我部署到我的 Azure 网站时发生。 (我目前使用的是免费网站,而不是 webrole/workrole 的东西)。我使用 webdeploy,它在以前的版本中工作正常,但我相信这与 nuget 包有关。

更新:我无法解决这个问题。我曾尝试通过 FTP 进行部署,在部署之前删除了整个文件夹,但这也不起作用。 Nuget 一直是一场噩梦。

最佳答案

将它放在您的 web.config 文件中。它将导致框架将依赖项重定向到适当的版本。

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<configuration>

从 future 编辑

当我由于上述语法中指出的 XML 错误而重新访问这篇文章时,还有一些其他地方很可能也需要更新。首先,在主 web.config 中,应在 <appSettings> 中更改此行以下部分

<appSettings>
<add key="webpages:Version" value="3.0.0.0" />

另外,views文件夹下有个web.config,应该更新成如下

 <configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>

基本上,除了程序集重定向之外,您还想识别所有提到 razor 2.0.0.0 的地方并将它们更改为 3.0.0.0。我相信我有上面确定的所有这些位置。

如果您更新整个 MVC 框架,还需要执行额外的工作,但这不是问题的基础。

关于.net - DotNetOpenAuth 导致无法加载程序集 System.Web.WebPages.Razor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19749416/

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