C# VS2010 Entering break mode failed

2019-02-02 03:45发布

问题:

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:

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:

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



回答3:

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

Build > Clean Solution Build > Build Solution (F6)



回答4:

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).


回答5:

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.



回答6:

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.



回答7:

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



回答8:

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.