我正在尝试在 Windows Azure 辅助角色中运行 SignalR 自主机服务器,但不断收到
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Owin, Version=2.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)
当我在控制台应用程序中运行相同的代码时,它运行良好并且一切都按预期工作。整个辅助角色是用 F# 编写的。下面是产生我正在讨论的异常的最短代码:
override wr.Run() =
let x : IAppBuilder = null
x.MapSignalR() |> ignore // this line throws the FileLoadException
当然,上面的代码不应该工作,但有不同的异常(exception)。通常我在 Startup 类 (WebApp.Start(url)) 的 Configuration() 方法中调用 MapSignalR。
我粘贴的异常详细信息来自计算模拟器,但我在实时云服务中得到了相同的信息。
您知道什么可能导致该问题或者我如何进一步诊断它吗?
最佳答案
这是 Nuget 的一个已知问题:请参阅 this 。不会为辅助角色项目自动添加绑定(bind)重定向。此失败的原因是 SignalR 二进制文件是依赖于 Microsoft.Owin 版本 2.0.0 构建的。但公共(public)源中 Microsoft.Owin 的最新可用版本是 2.0.2。要解决此程序集绑定(bind)问题,当您在控制台应用程序或 Web 应用程序上安装相同的 SignalR 包时,您将看到在 app.config 中自动添加程序集绑定(bind)重定向。由于 Nuget 客户端存在问题,在辅助角色项目中不会发生这种情况。要解决此问题,请将其添加到辅助角色项目的 app.config 中(或者尝试将 signalR 包添加到控制台应用程序,然后从其 app.config 复制粘贴绑定(bind)重定向):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
关于azure - 使用 F# 在 Azure 辅助角色中托管 SignalR 时出现 FileLoadException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20083185/