Troubleshooting: Resolving Could not load file or assembly '[assemblyname]' Error and Its Dependencies

Could not load file or assembly ‘[assemblyname]’ or one of its dependencies

“An attempt was made to load a program with an incorrect format.” That means that the assembly, which was to be loaded, was in an unexpected format. The format, in this case, refers most likely to 64-bit build of an application being deployed to IIS, which is being run in 32-bits.

By default, Visual Studio uses 32-bit version of IIS Express (Internet Information Services Express – the free lightweight web server that ships with some Windows versions and is useful for local development with Visual Studio) for your deployments.

If you’re building your solution in x64, running it in 32-bit IIS Express won’t work.

In my case, I was indeed building a 64-bit application. Therefore I also had to change the IIS to run in 64-bit version.

Solution: Change the IIS Express to run in 64b 

  1. You’ll need to enable 64-bit IIS Express from VS settings.
  2. Navigate to Visual Studio => Tools => Options => Projects and Solutions => Web Projects
  3. Select “Use the 64 bit version of IIS Express for web sites and projects”.
  4. Hit “OK” to save your changes. 


Popular Posts