Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileLoadException when hosting SignalR at Azure Worker Role with F#

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

exception

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?

like image 519
jakubka Avatar asked Mar 22 '23 14:03

jakubka


1 Answers

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>
like image 73
Praburaj Avatar answered Apr 06 '23 16:04

Praburaj