This post was most recently updated on May 26th, 2019.Reading Time: 2 minutes.
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.
The solution described in this post shows you how to resolve the issue when you’re deploying from Visual Studio, but get the error “Could not load file or assembly or one of its dependencies” when deploying to IIS or when opening your website after the deployment.
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!
Let me know whether it worked or not.
He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff.
This is his personal professional (e.g. professional, but definitely personal) blog.