Reputation: 5845
I am using Visual Studio 2010 on a 64 bit Windows 7 machine.
In Visual Studio I am creating a .NET 4 Visual C# ASP.NET Empty Web Application.
I add a Default.aspx file to the project with the text "Hello World".
If I select Debug -> Start Debugging it opens a web browser and correctly displays the text.
However, if I go into Properties -> Build -> Platform Target and change it to x64.
When I select Debug -> Start Debugging it opens a web browser with the following error message:
"Could not load file or assembly 'WebApplication' or one of its dependencies. An attempt was made to load a program with an incorrect format."
"Exception Details: System.BadImageFormatException: Could not load file or assembly 'WebApplication' or one of its dependencies. An attempt was made to load a program with an incorrect format."
However, I can deploy it to a separate 64 bit windows 2008 r2 IIS server on an application pool with "Enable 32-Bit Applications" set to False and the application runs fine even if I add 64 bit .dlls to the project.
Is it not possible to debug 64 bit applications in Visual Studio using the built in Visual Studio Development Server?
In the toolbar next to the Debug dropdown I only have one option "Any CPU":
Any help on this would be greatly appreciated.
Upvotes: 2
Views: 4393
Reputation: 1641
It has to do with debugging a 64 bit dll in a 32 bit application (the dev version of IIS used for debugging is 32 bit). You will have to do your debugging in 32 bit mode locally, and then target 64 bit upon deployment.
This question talks about a 64 bit replacement for the WebDev server used in Visual Studio 2010 Is Visual Studio 2010 WebDev WebServer (Cassini) 64-bit compatible?.
Microsoft's not so easy to use remote debugging for 64 bit web applications How to: Debug 64-Bit Applications.
Another thing you can try is installing IIS Express. It will run in 64 bit mode and can be used for debugging purposes. The linked article is actually for VS2013, but change the registry paths from 12.0 to 10.0 to make it work with VS2010.
For VS2013: Debugging VS2013 Websites Using 64-bit IIS Express
Command-Line:
reg add HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\WebProjects /v Use64BitIISExpress /t REG_DWORD /d 1
For VS2012: Allow for IIS Express 64 bit to run from Visual Studio 2012
You can configure Visual Studio 2012 to use IIS Express 64-bit by setting the following registry key:
reg add HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\WebProjects /v Use64BitIISExpress /t REG_DWORD /d 1
Upvotes: 7