title: Runtime error: Could not load file or assembly - Modules with different CPU types were found
body: <p>I'm getting the following runtime error in my WCF service.</p>
  
  <pre><code>Could not load file or assembly 'MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
  </code></pre>
  
  <p>After some looking around, I found a suggestion to use <a href="http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.90).aspx" rel="nofollow noreferrer">Assembly Binding Log Viewer</a>, or <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645" rel="nofollow noreferrer">Process Monitor</a>.  Neither or which yielded any information (that is, the log viewer showed nothing at all, and the process viewer didn't see the assembly load being attempted.</p>
  
  <p>I finally came across a suggestion to use <a href="http://www.dependencywalker.com" rel="nofollow noreferrer">this utility (dependency walker)</a> to find out what the assembly was actually looking for.  On opening, I got an error immediately; and the log stated the following:</p>
  
  <p>Error: Modules with different CPU types were found.
  Warning: At least one delay-load dependency module was not found.
  Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.</p>
  
  <pre><code>Error: Modules with different CPU types were found.
  Warning: At least one delay-load dependency module was not found.
  Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
  </code></pre>
  
  <p>According to the module list, it couldn't find these:</p>
  
  <pre><code>API-MS-WIN-CORE-COM-L1-1-0.DLL
  API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
  API-MS-WIN-CORE-WINRT-L1-1-0.DLL
  API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
  API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
  API-MS-WIN-SHCORE-SCALING-L1-1-0.DLL
  DCOMP.DLL
  IESHIMS.DLL
  </code></pre>
  
  <p>Some of these look like they relate to the RT framework; however, this application was developed in .NET 3.5 (actually, that's not strictly true - it was developed in 4.5 and downgraded to 3.5).</p>
  
  <p>Looking at some of these files seems to imply they are quite core Windows files, and oddly, I have used this dll elsewhere in the solution (admittedly on the client) without issue.</p>
  
  <p>I'm using VS2013 although I've tried VS2012 and get the same issue.</p>
  
  <p>I did come across <a href="https://stackoverflow.com/questions/17023419/win-7-64-bit-dll-problems">this question</a> which at first glance seems to be the same, although it relates to C++.</p>
  
  <p>Can anyone give me some guidance as to what the issue might be, or what to try next?</p>
  
  <p>Here is my fusion log:</p>
  
  <pre><code>=== Pre-bind state information ===
  LOG: DisplayName = MyAssembly.MyLib.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL (Fully-specified)
  LOG: Appbase = file:///c:/myprog/bin/Debug/
  LOG: Initial PrivatePath = NULL
  LOG: Dynamic Base = NULL
  LOG: Cache Base = NULL
  LOG: AppName = myprog.exe
  Calling assembly : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
  ===
  LOG: This bind starts in default load context.
  LOG: Using application configuration file: c:\myprog\bin\Debug\myprog.exe.config
  LOG: Using host configuration file: 
  LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
  LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
  </code></pre>
  
  <p>I managed to reduce the library in question down until it was just a single static function that returns a string, and still get the error.</p>