by Joakim

Could not load file or assembly 'xyz' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Having recently performed a complete wipe and OS re-install/upgrade on my work computer, I also had to get all my projects etc. up and running again. After getting the source for one of the ASP.NET applications I’m working on, I built the source and ran it using the VS Development Server, no problem at all. However, when I set everything up manually in IIS (not IIS Express, that also also worked like a charm), I got the the beautiful yellow screen of death. And since it had been a while since I set this particular project up to run in IIS on my computer, the error dumbfounded me for a while.

could-not-load-assembly-1

Visual Studio did provide me with a warning when building the solution though, which jogged my memory.

could-not-load-assembly-2

One of the project dependencies was built specifically for the x86 architecture, and when running the web app in IIS the default setting for any Application Pool is NOT to enable 32-bit applications (at least on a 64-bit computer). This is easy to fix though, open up IIS Manager, find the App Pool in question, go into “Advanced Settings” and change the value for “Enable 32-Bit Applications” to “True” (or alternatively, and perhaps even better, replace the offending reference dll with a compatible version if you can).

could-not-load-assembly-3

No more yellow screen of death! Smile