Visual Studio unable to load a program with an incorrect format.

Verify the bitness of the hosting application when you encounter this error.

Visual Studio 2013, for example, runs as a 32 bit process.  IIS Express also executes as a 32 bit process.  However, I just learned that a Windows Forms application being debugged in Visual Studio  2013 executes as 64 bit process.

A quick way to confirm the correct bitness is to identify the process under the task manager.  A 32 bit process will be appended with a *32.  Visual Studio for example is represented as devenv.exe *32.  However, the  Windows Forms application that was being debugged was represented as ApiTestClient.vshost.exe.

In our case, we had copied the 32 bit version of an unmanaged dependency from the bin folder of an ASP.NET classic application into the bin folder of the Windows Form application.  This was the problem.  We needed to use the 64 bit version of this dll worked instead.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s