首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何解决Azure角色部署中的System.Web.Http TypeLoadException问题?

如何解决Azure角色部署中的System.Web.Http TypeLoadException问题?
EN

Stack Overflow用户
提问于 2015-03-20 11:40:07
回答 2查看 2.1K关注 0票数 7

在我们的Azure服务中,我们使用Mvc、WebApi和Autofac。

Mvc和WebApi想要System.Web.Http版本5.2.3

Autofac.WebApi2想要5.2.0版

当部署到版本为5.2.3的Azure时,web角色无法从以下错误开始:

代码语言:javascript
运行
复制
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.

到目前为止,我已经尝试添加

代码语言:javascript
运行
复制
  <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在实例上,但我不认为它正在使用更改的文件(如果我通过删除关闭标记破坏配置文件,它不会抱怨)。

EN

回答 2

Stack Overflow用户

发布于 2016-02-28 09:35:10

这个回答的第二段帮助我解决了类似的问题:在您的problem项目中添加yourwebrolename.dll.config文件(带有“复制到输出目录”:“始终复制”选项)。有关此解决方案的更多信息可以在此链接上阅读。

票数 1
EN

Stack Overflow用户

发布于 2015-09-20 12:25:50

我也有同样的错误,我通过在我的web.config文件中添加以下内容来解决这个问题

代码语言:javascript
运行
复制
    <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,您现在将其作为

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29165689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档