gpt4 book ai didi

azure - MVC4 Azure 发布错误 - 无法加载文件或程序集 'System.Web.Razor'

转载 作者:行者123 更新时间:2023-12-02 09:39:52 25 4
gpt4 key购买 nike

该项目在本地运行良好,仅在发布时出现以下错误:

Could not load file or assembly 'System.Web.Razor' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

过去几个小时在谷歌上搜索后,问题似乎是我添加到项目中的 nuget 包引用了 razor 1 并覆盖了我的 razor 2 dll。我尝试将 razor 2.0.0.0 dll 复制到引用而不是 1 但错误仍然存​​在。这是详细构建输出中显示冲突的地方:

There was a conflict between "System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
1> "System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
1> References which depend on "System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll].
1> C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll
1> Project file item includes which caused reference "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll".
1> System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
1> References which depend on "System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Users\Jack\SkyDrive\LessonUp.Current\packages\RazorEngine.3.0.8\lib\net40\System.Web.Razor.dll].
1> C:\Users\Jack\SkyDrive\LessonUp.Current\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll
1> Project file item includes which caused reference "C:\Users\Jack\SkyDrive\LessonUp.Current\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll".
1> System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
1> Recaptcha
<小时/>

从那里它继续列出取决于 razor 2 的其他软件包。

我添加到项目中的包是:Recaptcha、Recaptcha.mvcModel 和 Postal。
有谁知道我可以采取什么步骤来解决这个问题?
如果我可以提供更多可能导致解决方案的信息,请告诉我。

最佳答案

确保引用 2.0 dll 并复制 local = true,然后尝试在 web.config 中添加程序集绑定(bind)重定向:

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

关于azure - MVC4 Azure 发布错误 - 无法加载文件或程序集 'System.Web.Razor',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14864670/

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