It turns out you can also get this error from mixing up your 32-bit and 64-bit DLLs. Running in the Visual Studio debugger with Cassini as your webserver, everything’s 32-bit, but if you try to run a 64-bit website and one or more DLLs are compiled as x86, you get this error as well. I tracked it down by setting a virtual directory on my local IIS7 on my Vista x64 developer’s rig to point to the code which was working when I pressed F5, but failing on the production server. Pointing at the PrecompiledWeb gave the same result as on the production server, but pointing at the source code told be which DLL was an "invalid image" or some such nonsense – i.e. the one compiled for the wrong target architecture.