This post was most recently updated on January 7th, 2019.
This post describes how to fix the “Could not load file or assembly ‘[assemblyname]’ or one of its dependencies. An attempt was made to load a program with an incorrect format.” error.
Especially while installing a new dev machine, and building your project for the first time, you may end up getting the following exception:
Could not load file or assembly '[assemblyname]' or one of its dependencies. An attempt was made to load a program with an incorrect format.
No fear, though, as this is usually easily fixed. In quite a few cases, it’s simply a mismatch between architectures and easily changed.
The latter part of the error message should point you
By default, Visual Studio uses 32-bit version of IIS Express for your deployments. In case you know what you’re doing, it’s safe and easy to change this, though. If you’re building your solution in x64, running it in 32-bit IIS Express won’t work.
In my case, I was building a 64-bit application. Therefore I also had to change the IIS to run in
Solution: Change the IIS Express to run in 64b
Okay – see the steps below.
How to change IIS Express to run in 64-bit
- You’ll need to enable 64-bit IIS Express from VS settings:
- Navigate to Visual Studio – Tools – Options – Projects and Solutions – Web Projects
- Select “Use the
64 bitversion of IIS Express for web sites and projects”
- Hit “OK” to save your changes.
See the screenshot below:
And you should be golden!
Latest posts by Antti K. Koskela (see all)
- Fixing “-2147024891, System.UnauthorizedAccessException” when accessing SharePoint SOAP Web Services - January 17, 2019
- “500 Internal Server Error” after switching a WordPress site to PHP 7.3 - January 15, 2019
- Azure Functions failing on “OPTIONS” call? Quick fix! - January 9, 2019
- Thanks for an amazing 2018! - December 28, 2018