title: Load different assembly depending on build configuration
body: <p>I am using <a href="https://magick.codeplex.com/" rel="nofollow">Magick.NET</a> in my project, which renders maps of a game. Is it possible to load the X86 version when I build the tool for x86 processors and the X64 version of Magick.NET for 64bit processors? I guess the the main problem is, that the different versions of the dll have different identities.</p>
  
  <p>I have written a prebuild event which copes the right dll on build, depending on the selected build configuration. I also loaded the copied assembly using <code>Assembly.LoadFrom();</code>, but the app always throws an exception that the assembly I added to references in VS2010 was not found. I can not add both references because they have the same namespace and the same methods.</p>
  
  <p>Is there a better way to handle this except changing the reference in VS2010 for each build configuration?</p>
  
  <p>Prebuild process:
  </p>
  
  <pre><code>echo."$(ConfigurationName)"|findstr /C:"x64" &gt;nul 2&gt;&amp;1
  if not errorlevel 1 (
     copy /Y "$(ProjectDir)lib\Magick.NET-x64.dll" "$(TargetDir)lib"
  ) else (
     copy /Y "$(ProjectDir)lib\Magick.NET-x86.dll" "$(TargetDir)lib"
  )
  </code></pre>
  
  <p>Load assembly on x86 build:
  </p>
  
  <pre><code>if (IntPtr.Size == 4)
  {
      Assembly assembly = Assembly.LoadFrom("lib/Magick.NET-x86.dll");
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>System.BadImageFormatException
  Magick.NET-x64, Version=6.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec not found
  </code></pre>