title: How to combine two managed x86/x64 dlls into one managed AnyCpu library?
body: <p>A third party compiles unmanaged code (x86/x64 separated) and provides managed C# .NET dlls for either platform (x86/x64 separated):</p>
  
  <ul>
  <li>FooManaged_x86.dll</li>
  <li>FooManaged_x64.dll</li>
  </ul>
  
  <p>This is what I receive (neither native code, nor unmanaged dlls).</p>
  
  <p>I can then create a C#.NET application (or library) targetting either x86 or x64 and directly reference the corresponding managed dll - all fine, but restricted to one particular platform (not my goal).</p>
  
  <p>My application can target AnyCpu (my goal), reference the x64 dll (bad, compiler warning), and it will work only when it actually runs as x64. Again, this is bound to one particular platform.</p>
  
  <p>I know, that I can combine <em>unmanaged</em> x86/x64 dlls (with Fody.Costura) into one managed dll by dynamically loading the approriate dll at runtime (using DllImport and manual AssemblyLoad under the hood). I've done this with great success, but this method is not well suited for <em>managed</em> dlls. I would have to PInvoke from managed C# into managed C# dlls - which sounds wrong to me.</p>
  
  <p><strong>Q:</strong> Is there any way to combine two managed x86/x64 dlls into one managed AnyCpu dll without PInvoke?</p>