无法在Azure上加载文件或程序集Microsoft.Owin

时间:2017-06-30 02:32:05

标签: asp.net azure signalr owin assembly-binding-redirect

我的ASP.Net MVC应用程序在IIS上本地运行时工作正常,但在部署到Azure时出现以下错误:

<div id="bg"></div>

这是堆栈跟踪的一部分让我相信SignalR是一个潜在的罪魁祸首:

Could not load file or assembly 'Microsoft.Owin, Version=2.1.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)

根据NuGet,我在应用程序上安装了3.0.1版本的Microsoft.Owin,但显然某些东西(SignalR)需要2.1.0版本。我原以为bindRedirect会强制SignalR使用已安装的3.0.1版本(在Azure上的/ bin中验证为当前版本3.0.1):

[FileLoadException: Could not load file or assembly 'Microsoft.Owin, Version=2.1.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)]
   Owin.OwinExtensions.MapSignalR(IAppBuilder builder, String path, HubConfiguration configuration) +0
   Owin.OwinExtensions.MapSignalR(IAppBuilder builder, HubConfiguration configuration) +12
   QuikWorx.O365Web.Startup.Configuration(IAppBuilder app) +169

......但是,唉,事实并非如此。

我也尝试了以下但没有成功:

  • 强制重新安装带有NuGet的Microsoft.Owin 3.0.1。
  • 强制重新安装需要带有NuGet的Microsoft.Owin 2.1.0的SignalR组件(Microsoft.AspNet.SignalR.Core)
  • 将Microsoft.Owin的bindingRedirect的oldVersion更改为“0.0.0.0-2.1.0.0”(这没有意义)
  • 删除Microsoft.Owin的bindingRedirect
  • 使用Kudu中的 <dependentAssembly> <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> </dependentAssembly> 删除网站目录中的所有文件和文件夹

还有什么我可以尝试的吗?

1 个答案:

答案 0 :(得分:0)

很想找到问题的根本原因,例如为什么它在本地运行,但不在Azure中运行,但基于此answer,您应该尝试安装Microsoft OWIN本身 - 通过NuGet,直接对于失败的项目。