title: Reference two equal assemblies, only public keys differ
body: <p>My Visual Studio 2008 project references two (external) assemblies (A+B) both of which happen to be referencing the same third assembly (C). However, assembly A expects assembly C to have a public key which is different from what assembly B expects it to have.</p>
  
  <p>Here's an example of the obvious exception:</p>
  
  <blockquote>
    <p>Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=9ad232b50c3e6444' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)</p>
  </blockquote>
  
  <p>Ofcourse, I would not be able to put both versions of C (only differing by public key) in the same directory, as their filenames are equal. Second, I've found that using assembly binding from the configuration file only allows version mapping, not public key mapping. </p>
  
  <p>I've also tried to put one of the assemblies C in a separate directory and configure the CLR to search in that directory when loading assemblies. I could not get that to work unfortunately.</p>
  
  <p>I'm aware that recompiling one of the external libraries (one of them happens to be open sourced) would fix this problem but I don't want to add that burden to my maintenance plan if it is not absolutely necessary.</p>
  
  <p>So my question is: how would I reference both 'versions' of assembly C, which only differ by public key?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I stumbled upon <a href="https://stackoverflow.com/questions/2460542/using-different-versions-of-the-same-assembly-in-the-same-folder/2460626#2460626">this answer</a> to a related question, providing an interesting solution using ilmerge. I haven't checked it out yet but it may be useful to anyone struggling with this problem.</p>