在我们的Azure服务中,我们使用Mvc、WebApi和Autofac。
Mvc和WebApi想要System.Web.Http版本5.2.3
Autofac.WebApi2想要5.2.0版
当部署到版本为5.2.3的Azure时,web角色无法从以下错误开始:
WaIISHost
Role entrypoint could not be created: System.TypeLoadException: Unable to load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Http, Version=5.2.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)
File name: 'System.Web.Http, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Http, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///E:/approot/bin
LOG: Initial PrivatePath = E:\approot\bin
Calling assembly : Autofac.Integration.WebApi, Version=3.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\base\x64\WaIISHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from D:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Http, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///E:/approot/bin/System.Web.Http.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
到目前为止,我已经尝试添加
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
并将其放置在MyAccountView.dll.config文件夹中,但错误保持不变(包括使用WaIISHost.exe.config的行)。
我也尝试过修改WaIISHost.exe.config文件,而RDPing在实例上,但我不认为它正在使用更改的文件(如果我通过删除关闭标记破坏配置文件,它不会抱怨)。
发布于 2016-02-28 09:35:10
这个回答的第二段帮助我解决了类似的问题:在您的problem项目中添加yourwebrolename.dll.config文件(带有“复制到输出目录”:“始终复制”选项)。有关此解决方案的更多信息可以在此链接上阅读。
发布于 2015-09-20 12:25:50
我也有同样的错误,我通过在我的web.config文件中添加以下内容来解决这个问题
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.3.0" />
</dependentAssembly>
我能看到你在用
将旧版本更改为0.0.0.0-5.2.2.0,您现在将其作为
https://stackoverflow.com/questions/29165689
复制相似问题