How do I resolve 'BadImageFormatException' when using 64-bit version of PDFNet for .NET?

Q: How do I resolve 'BadImageFormatException' when using 64-bit
version of PDFNet for .NET in Visual Studio Web Server?

I get the following error:

[BadImageFormatException: Could not load file or assembly 'PDFNet' or
one of its dependencies. An attempt was made to load a program with an
incorrect format.]

I am using 64-bit version of 64-bit machine, so why do I get this

A: The problem may be related to Visual Studio Web Server which is by
default 32-bit - even on 64-bit systems.

From '64-bit read me.txt':

"If you are running a 64-bit version of this sample project, it must
be run on 64-bit web server or an error will be generated. Visual
Studio's development web server is only available in 32-bit, so visual
studio must be configured to use a 64-bit version of IIS, or
alternatively, a 64-bit version of CassiniDev. CassiniDev is "a fully
compatible drop-in replacement for the Visual Studio 2008/2010
development server". CassiniDev is available from

Alternatively, the 32-bit version of PDFNet can be used for

Btw. you could use 32 bit version of PDFNet on both systems. In this case in your IIS 2008 R2 Web Server application pool, set the Identity to “LocalSystem” (for both .NET 2.0 and .NET 4.0). Also, make sure to set the “Enable 32-Bit Applications” to “True”.

Latest versions of Visual Studio now include 64bit IIS. You can set this by going to Tools → Options → Project and Solutions → Web Projects and checking “Use the 64 bit version of IIS Express”