title: Mixing 32-bit and 64-bit P/Invokes
body: <p>I've run into a problem that I'm pretty sure I know the answer to, but I figured I'd at least ask and see if there was some "magic bullet" that might save me a huge headache.</p>
  
  <p>Here's the high-level view.</p>
  
  <p>I have a managed application.  This application interfaces with hardware via third-party libraries from different vendors.  I have full control over the consuming managed app and zero control over the hardware API libraries.</p>
  
  <p>Vendor A provides only a 32-bit native SDK.  To allow us to use it on 64-bit systems, we marked the application to run in 32-bit mode.  All was well.</p>
  
  <p>We are now integrating with Vendor B, which provides 64-bit-specific native API libraries on 64-bit machines.  The 32-bit native DLL from Vendor B will not work on a 64-bit system (tried that).  If I build a test harness running as 64-bit or AnyCPU, it works fine.  If I mark it as 32-bit, it fails on the P/Invoke calls.</p>
  
  <p>It seems that Vendor A and Vendor B hardware are going to be mutually exclusive on 64-bit PCs, but I'm wondering if anyone has suggestions on how to possibly work around that.</p>