C# – Debugging x86 .NET application on Windows x64 in VS2008

64-bitcdebuggingvisual studiovisual-studio-2008

I use the x64 version of Windows 7. My application use some COM servers (usual native x86 COM Servers) that can't be loaded in x64 context. So I decided run it as a x86 application using WOW so I set platform target as x86.

But Visual Studio 2008 debugger started to show messages like "The source file is different…." for all source files when I try debug it. What is reason for this behaviour? This question was born there "The source file is different…." message in Visual Studio 2008 is result of debugging x32 apps on x64 Windows

Update: I cleaned solution, rebuilt solution, removed obj, bin and etc. folders, restarted computer, reinstalled Visual Studio… So, what else could be the problem?

Update2: If you create new Windows Application project and change target platform to x86 you will see this trouble. But if you delete Settings1.settings from project the trouble will be eliminated!!. Any Idea?

Update3: http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/bc297668-65b4-46e8-969e-c7a6340d33b6

Best Answer

The error message you are getting is unrelated to debugging a WOW64 bit application. It's even less of an issue here because Visual Studio runs a 32 bit process inside of WOW64. So instead of x64 -> x86 you are actually doing an x86 -> x86 debugging session.

What's going on here is that Visual Studio is reading the checksum for the source files out of the PDB and it does not match the checksum of the files you are using to debug the application. The most likely causes for this are

  • Out of date PDB's
  • Using the incorrect source files. This is more common than you think in branching scenarios where you could easily grab the wrong version of the file.

The way I typically debug through this is

  • Close VS and manually delete all of the binaries and binary directories
  • Restart VS and rebuild
  • Close VS
  • Restart VS and attach to the running project without opening the solution
  • Then manually open the files