This project has moved and is read-only. For the latest updates, please go here.

Dependency on Microsoft.Owin, Version 2.0.0.0

Oct 30, 2013 at 9:08 PM
I'm trying to build a new ASP.NET Web API project and host it using Katana in a Windows Azure worker role. I'm following the guidance outline in http://www.asp.net/web-api/overview/hosting-aspnet-web-api/host-aspnet-web-api-in-an-azure-worker-role.

I've installed the Microsoft.AspNet.WebApi.OwinSelfHost package. It seems there is a fixed dependency on version 2.0.0.0 of the Microsoft.Owin assembly. The rest of the assemblies are OK with version 2.0.1.

When trying to run the project, I get an error on the app.UseWebApi(config) line in the code below:
class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute("Default", "{controller}");

            app.UseWebApi(config);
        }
    }
The error is:
_=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Owin, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///D:/Projects/Demos/WindowsAzure3/WindowsAzure3/csx/Debug/roles/WorkerRole1/approot
LOG: Initial PrivatePath = D:\Projects\Demos\WindowsAzure3\WindowsAzure3\csx\Debug\roles\WorkerRole1\approot

Calling assembly : System.Web.Http.Owin, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Projects\Demos\WindowsAzure3\WindowsAzure3\csx\Debug\roles\WorkerRole1\approot\WorkerRole1.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Owin, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///D:/Projects/Demos/WindowsAzure3/WindowsAzure3/csx/Debug/roles/WorkerRole1/approot/Microsoft.Owin.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated._
Nov 1, 2013 at 4:21 PM
Edited Nov 1, 2013 at 4:24 PM
Thanks to @tracher, I've foud a workaround:

Open the app.config file and add the <runtime> node into the configuration node:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin"
          publicKeyToken="31bf3856ad364e35"
          culture="neutral" />
        <bindingRedirect oldVersion="2.0.0.0" newVersion="2.0.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  ...

</configuration>
to it.

Now everything should work :-)