title: Could not load assembly during runtime although binding redirect is correctly set
body: <p>I have a <strong>unit test project .NET 4.6.1</strong> where some tests fail prolly because I added a new project as a new reference to the unit test project.</p>
  <p>This is the error I am getting:</p>
  <pre><code>Error: System.IO.FileLoadException: 
  Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.1.0, 
  Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies.
   The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).
  </code></pre>
  <p>Then I added this configuration to the <strong>app.config</strong> of the <strong>unit test project:</strong></p>
  <pre><code>  &lt;runtime&gt;
      &lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name=&quot;Microsoft.Extensions.DependencyInjection.Abstractions&quot; publicKeyToken=&quot;adb9793829ddae60&quot; culture=&quot;neutral&quot; /&gt;
          &lt;bindingRedirect oldVersion=&quot;0.0.0.0-1.1.1.0&quot; newVersion=&quot;1.1.1.0&quot; /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
  </code></pre>
  <p>But the test still fails with SAME error messsage.</p>
  <p>Why did the binding redirect not help?</p>
  <p>I have of course also these props in the unit test .csproj file:</p>
  <pre><code>&lt;AutoGenerateBindingRedirects&gt;true&lt;/AutoGenerateBindingRedirects&gt;
  &lt;GenerateBindingRedirectsOutputType&gt;true&lt;/GenerateBindingRedirectsOutputType&gt;
  </code></pre>
  <p>When I check the generated unit.test.config file in the debug folder it does contain many binding redirects BUT not the one why my tests fail...</p>
  <p>Just discovered this in the output box after rebuild solution:</p>
  <p>NU1605: Detected package downgrade: Microsoft.Extensions.DependencyInjection from 2.2.0 to 1.1.1. Reference the package directly from the project to select a different version.</p>
  <pre><code> UnitTests -&gt; MyNewReferencedProject -&gt; Microsoft.ApplicationInsights.WorkerService 2.14.0 -&gt; Microsoft.Extensions.DependencyInjection (&gt;= 2.2.0) 
  
   UnitTests -&gt; Microsoft.Extensions.DependencyInjection (&gt;= 1.1.1)
  </code></pre>
  <p>Is this &quot;warning&quot; related to my problem in any way because my problem is about assembly <code>Microsoft.Extensions.DependencyInjection.Abstractions</code></p>
  <p>and <strong>not</strong> about <code>Microsoft.Extensions.DependencyInjection</code></p>
  <p>I have these assembly versions of the Microsoft.Extensions.DependencyInjection.Abstractons.dll in all debug\bin folders of my solution projects.</p>
  <p>It seems I have 3 different versions floating around...</p>
  <p><a href="https://i.stack.imgur.com/V4ZbG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V4ZbG.png" alt="enter image description here" /></a></p>
  <p>This is really funky... when I add now this binding redirect:</p>
  <pre><code> &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name=&quot;Microsoft.Extensions.DependencyInjection.Abstractions&quot; publicKeyToken=&quot;adb9793829ddae60&quot; culture=&quot;neutral&quot; /&gt;
          &lt;bindingRedirect oldVersion=&quot;0.0.0.0-2.1.0.0&quot; newVersion=&quot;2.1.0.0&quot; /&gt;
        &lt;/dependentAssembly&gt;
  </code></pre>
  <p>The former runtime exception is gone because I get a new one.</p>
  <p>It seems I fixed it but... this is wonky tonky stuff. Random shit...</p>
  <p>Why was it fixed using 2.1.0.0 ???</p>
  <p><strong>@Mark Gravell</strong></p>
  <p>There is no inner exception its NULL.</p>
  <p>Thats the message:</p>
  <pre><code>Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  </code></pre>
  <p>odd is my tests are not really executed I mean I can not debug them. They just start and immediatelly I get this exception face slammed!</p>