diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 8e417d563a..6d1d1a7303 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Text; using System.Windows.Forms; @@ -219,11 +220,12 @@ namespace ICSharpCode.SharpDevelop.Debugging public static void ToggleBreakpointAt(IDocument document, string fileName, int lineNumber) { - foreach (Bookmark m in document.BookmarkManager.Marks) { - BreakpointBookmark breakpoint = m as BreakpointBookmark; + ReadOnlyCollection bookmarks = document.BookmarkManager.Marks; + for (int i = bookmarks.Count - 1; i >= 0; --i) { + BreakpointBookmark breakpoint = bookmarks[i] as BreakpointBookmark; if (breakpoint != null) { if (breakpoint.LineNumber == lineNumber) { - document.BookmarkManager.RemoveMark(m); + document.BookmarkManager.RemoveMark(breakpoint); return; } }