I am trying to run SignalR self host server in the Windows Azure Worker Role, but keep getting the
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)
When I run the same code in the console application it runs fine and everything works as expected. The whole worker role is written in F#. Below is the shortest code which produces the exception I am talking about:
override wr.Run() =
let x : IAppBuilder = null
x.MapSignalR() |> ignore // this line throws the FileLoadException
Of course the code above should not work, but with different exception. Normally I call MapSignalR in the Configuration() method of the Startup class (WebApp.Start(url)).
The exception detail I pasted is from the Compute emulator, but I get the same thing at the live Cloud Service.
Do you have any idea what can cause the problem or how can I diagnose it further?
This is a known issue with Nuget : Refer this. Binding redirects not getting added automatically for worker role projects. The reason for this failure is SignalR binaries are built with a dependency over Microsoft.Owin version 2.0.0. But the latest available version of Microsoft.Owin in the public feed is 2.0.2. To fix this assembly binding issue when you install the same SignalR packages on a console application or a web application you will see assembly binding redirects being automatically added for you in the app.config. Due to an issue with Nuget client this is not happening in case of worker role projects. To fix this issue add this to your worker role project's app.config (Alternatively try adding your signalR package to a console app and copy paste the binding redirects from its app.config):
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With