Enabling 64-bit web application debugging with IIS Express using Visual Studio 2013
Posted: (EET/GMT+2)
Visual Studio provides application debugging support for both 32 and 64 bit applications, but if it happens your application is an ASP.NET web application, then there's a single limitation when using IIS Express as you web server.
To elaborate, when you run your ASP.NET web application as a 64-bit application, the default configuration for IIS Express web server (which comes installed with Visual Studio) does not allow debugging. Instead, you might see an error message similar to this:
Server Error in '/' Application. Could not load file or assembly 'MyAspNetWebApp' or one of its dependencies. An attempt was made to load a program with an incorrect format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.BadImageFormatException: Could not load file or assembly 'MyAspNetWebApp' or one of its dependencies. An attempt was made to load a program with an incorrect format.
To fix this, you must specifically enable 64-bit debugging for IIS Express in the system registry. This is done using the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\WebProjects\Use64BitIISExpress
This registry key "Use64BitIISExpress" is of type DWORD, and its value should be 1 (one). If the key doesn't exist, simply create it. Once you have this registry setting in place and have restarted IIS Express, you should be good to go.
Of course, the other way around this is to simply switch your application back to a 32-bit mode.