Search code examples
c#dependencies.net-assemblyassembly-resolution

Looking for strategy to resolve: Could not load file or assembly


I have an issue with the following error: "Could not load file or assembly". The error speaks for itself: Micorsoft.Owin version 2.0.0.0 fails to load in System.Web.Http.Owin. But I want to use Microsoft.Owin 3.0.0.0 and the dll of System.Web.Http.Owin I do reference has version 5.2.2.0 which on its own should work with Microsoft.Owin.

So my question here is who is referencing Micorsoft.Owin version 2.0.0.0?

And therefore: How can I find out which assembly is asking for Micorsoft.Owin 2.0.0.0?

Are there a recommended strategy for such issues?

What I tried to do so far is adding a binding redirect. But this would more be a workaround rather than a nice solution (and it did not work btw.):

 <dependentAssembly>
    <assemblyIdentity name="System.Web.Http.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>

Solution

  • You can use the tool Fuslogvw.exe to get a log of assembly bindings, in particular what loaded what and where it looked for the assemblies.

    It's installed with Visual Studio, but to run it you will need to open a Visual Studio command prompt (like this) and then run

    fuslogvw