问题
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:
- 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.
- 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