Search code examples
visual-studio-2010breakpointswindows-7-x64

Visual Studio - Some breakpoints not breaking


I have a solution in Visual Studio 2010 with 9 projects which is under source control with Source Safe. I just recently swiped my hard-drive and upgraded to Win7 x64 from WinXP x86 (long overdue!). When I checked the solution out to the "new" machine, some parts are not working correctly now, so I'm trying to debug it.

Perhaps worth noting is that I was working in VS2008 before. When I upgraded, I first opened the project in VS2008 to make sure it worked and I noticed there were problems that I needed to debug. I set some breakpoints and a couple worked and a couple didn't. I couldn't immediately figure out why some weren't breaking, so I decided to go ahead and upgrade the project to VS2010 hoping it would work itself out. It didn't.

The main project calls a public sub in a public module in a project that is a library referenced by every other project. I have a breakpoint on the main form Form_Load which breaks successfully as soon as the code begins running. The Form_Load calls the aforementioned public sub which also has a breakpoint. But that breakpoint DOES NOT break. In other words, the debugger will stop on the call ProjectStartupActions() but will not stop on the definition Public Sub ProjectStartupActions() or any line in it.

If I "Go To Definition" on the sub call in Form_Load, it jumps to the correct place where I have the breakpoint, so I'm certain I've placed the breakpoint correctly.

My Project >> Debug >> Configuration is set to "Active (Debug)" and Platform is "Active (Any CPU)" for all projects. To further confirm that it should be running in Debug rather than Release, if I open an explorer window to the "Debug" folder for the library project and clean the project, the folder empties out. When I rebuild or run the files are all replaced.

Thanks for any help.

Oh yeah, also I made a change to the code of Public Sub ProjectStartupActions(). I added MsgBox("Hello") to the first line in the sub, but it never pops up.


Solution

  • Set the target to x86 to debug it. – Hans Passant

    This worked! Thanks!! I used the Configuration Manager to change the target for the entire solution to x86.

    But why did it work? Why did the "Any CPU" option break on the main project but not the library?