BadImageFormatException debugging web site running in x64 mode
Try to follow the instructions from Debugging VS2013 Websites Using 64-bit IIS Express:
If you are working on ASP.NET MVC web sites in Visual Studio 2013 (VS2013), you need to make one registry change if you want to run IIS Express as a 64-bit process by default. Use one of the methods, below.
Command-Line:
reg add HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\WebProjects /v Use64BitIISExpress /t REG_DWORD /d 1
In my case, for Visual Studio 2019, there was no need to edit the registry manually. I followed the instructions found here.
When you launch a web project in Visual Studio, by default it uses the 32-bit version of IIS Express. To change that you can enable the 64-bit version through Options.
So, head to:
Tools --> Options --> Project and Solutions --> Web Projects
Check the option “Use the 64 bit version of IIS Express for web sites and projects”
This fixed it for me.
You can use Fuselogvw.exe. This utility dumps all Fusion activity to a log. You can then go through the log and check which DLL is of the wrong format. You have to also see what AgileEFLib
actually depends on. Maybe the DLL itself is not the problem but one of its dependencies.
I guess that one of the dependency DLLs in your website is compiled as an x86.
Edit: Also see Dependency Walker. This one shows all dependencies and their architecture.