Azure webrole cycling and “Could not load file or assembly System.Web.Http 5.2.0.0”

北城余情 提交于 2019-12-23 18:14:42

问题


I can't deploy my azure webrole anymore, it's cycling indefinitly. So I put on Intellitrace and I found this exception :

Exception:Thrown: "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.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)

In my project, web.config and package (Webapi, webhost etc.) are all in 5.2.0.0 so I don't understand why Azure try to find 5.0.0.0 ?!

Example:

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
</dependentAssembly>

Do you have any idea ? Thanks

ps: System.Web.Http got copy local:true


回答1:


That intellitrace output is telling you that WaIISHost.exe is crashing ("Unable to load the role entry point"). But your web.config assembly binding redirect is only affecting the w3wp.exe process. You have a couple options:

  1. Check your role entry point (the class that derives from RoleEntryPoint, typically WebRole.cs) to make sure you are referencing System.Web 5.2 DLLs.
  2. Create a .config file with your binding redirect for the WaIISHost process. To do this you would create a .dll.config. In a default web role project this would be WebRole1.dll.config.


来源:https://stackoverflow.com/questions/24921869/azure-webrole-cycling-and-could-not-load-file-or-assembly-system-web-http-5-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!