31

I was having some problems with my breakpoints later in my program saying that they would not be hit because the source code and the compiled code was different. I decided to put a break point on my public MainWindow() function, and see what happened.

Now I get the error that Entering break mode failed for the following reason: Source file 'F:\cAdmin\OO\OO\MainWindow.xaml.cs' does not belong to the project being debugged.

I find this funny because my project is stored on my flash drive (L:) and not F:.

I have rebuilt my project and cleaned it (many times), restarted my computer, moved my Flash drive, and anything else that I can think of.

1

8 Answers 8

55

Delete the solution user options (.suo) file.

If you experience "funny" debugging issues, it usually means the suo file is corrupt.

Delete the solutions suo file. This has fixed weird debugging problems with breakpoints every time for me. Note, you will lose your solution settings, such as bookmarks, breakpoints, and such.

See Visual Studio 2008 - The breakpoint cannot be hit.

2
  • and if you have multiple projects in a solution then after deleting (.suo) files right click and set the desired startup project in VS
    – GorvGoyl
    Commented Oct 15, 2015 at 8:38
  • 1
    This fix worked for me just now. I was getting some really strange behaviours due having taken a copy of a solution and then having both copies open at the same time. Commented Mar 17, 2016 at 16:52
19

Visual Studio 2012 Update 3

Didn't work:

  • Rebuild Solution
  • delete .SUO
  • Delete Obj and Bin directories

Did work:

Tools->Options->Debugging->Edit and Continue->uncheck Edit and Continue checkbox

14

Tried this, but it didnt work. For me in the end solved:

Build > Clean Solution Build > Build Solution (F6)

2
  • This sort of worked for me, except I had to clean the specific project, not the solution. As an additional note, the Visual Studio error seemed to originate when I created a new, empty solution and added in a few existing .csproj projects. Commented May 6, 2014 at 19:41
  • I cleaned solution, then rebuilt solution and the issue went away.
    – Dib
    Commented Jul 24, 2015 at 6:06
1

I had this on a set of solutions we started to maintain for a client and migrated to Visual Studio 2010. The "delete the .suo file" did not work.

Somehow the set of sources included two assembly projects into the same directory, sharing one source file file. That file itself was not in the warning dialog.

This solved the problem:

  1. split the assembly projects in separate directories, and
  2. move the shared file into a 3rd assembly (also in a separate directory).
1

The solution for me was a little more esoteric to say the least! I had a workflow.xaml in an Azure WorkerRole project and it was set to BuildAction: XamlAppDef instead of None. For some reason, this caused the project to fail to pick up any changes to other files - even though VS2013 reported a successful build - which resulted in the "Entering break mode failed" error when attempting to debug the WorkerRole.

Other symptoms included types not being recognized (i.e. coloured by the IDE) and intellisense not working. Setting the xaml file build action to "none" fixed the problem (I dynamically load the workflow in any case).

I mention this just in case someone else has done something similar and the other solutions do not work.

1

I had a library project A and a web project in my solution. Needed to add a project reference of project B to library project A for debugging. Did that but it wouldn't work.

Problem was that the web project was also referencing project B via DLL; so I also needed to change that to a project reference as well and then it worked.

1

For me, selecting Project|Add Existing Item, and then selecting the file named in the error message worked.

0

I had the same issue when I was trying to copy over a project that was not in source control.

The solution to the problem was that the bin directory was marked as read only (must have happened during the copy) and as a result the project was running on libraries built on a different host and it was unable to step through.

Make sure you manually delete all items in the bin directory and make sure the 'bin' directory can be written to.

Not the answer you're looking for? Browse other questions tagged or ask your own question.