title: How do I make assembly redirection work in a .net 4.0 web app
body: <p>I am working on a web-based application using asp.net 4.0. </p>
  
  <p>I have some dlls I am using in the GAC that have some embedded dependencies on older dlls.</p>
  
  <p>I have Configured the assemblies so that the dependency redirects to the correct version of the dll on my machine. This works perfectly in a 3.5 or lower version application, however, when I try to build an asp.net 4.0 application based on the same dlls, it chokes with an error like: </p>
  
  <pre><code>Could not load file or assembly 'ControlReferencedByMyDll, Version=2.0.0.0, 
  Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXXXX' or one of its dependencies.
  The located assembly's manifest definition does not match the assembly reference. 
  (Exception from HRESULT: 0x80131040) 
  </code></pre>
  
  <p>where my version of ControlReferencedByMyDll is version 2.0.1.0. </p>
  
  <p>I could not find a GAC configuration utility for .net 4.0, but in my machine.config (In both the Framework and Framework64 folders for .net 4.0)  I have added something like:</p>
  
  <pre><code>&lt;runtime&gt;
    &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
      &lt;dependentAssembly&gt;
        &lt;assemblyIdentity name="ControlReferencedByMyDll" PublicKeyToken="XXXXXXXXXXXXXXXX"/&gt;
        &lt;bindingRedirect oldVersion="1.0.0.0-9.9.9.9" newVersion="2.0.1.0"/&gt;
      &lt;/dependentAssembly&gt;
    &lt;/assemblyBinding&gt;
  &lt;/runtime&gt;
  </code></pre>
  
  <p>to see if that was the problem. </p>
  
  <p>I've even tried to add the appliesTo="v2.0.50727" attribute to the assemblyBinding to see if it made a difference. </p>
  
  <p>but it does not seem to have.</p>
  
  <p>Has anyone else had this problem? and more importantly, can anyone help me solve this?</p>