简体   繁体   中英

Debugger stops when there is no breakpoint VS2010

I recently changed one of the options in the debugger and I think that is what is causing this problem but I can't seem to 'undo' it...I google and all hits come back with the opposite 'why does the debugger not stop on a breakpoint'

anyway can someone shed some light?

EDIT: when I press f5 in debug mode. Everytime. It goes into the Program.cs and stops on

Application.SetCompatibleTextRenderingDefault(false);

in the Main()

Old thread I know, But I just encountered the same problem. All I did was a Delete All Breakpoints (Ctrl+Shift+F9 for me), then a Clean on my startup project, followed by a Rebuild, then Run. After that it stopped breaking where there were no breakpoints.

I just experienced the same problem however mine isn't due to a option change. I think I have found the reason why but no resolution to fix it. I have a Solution with multiple projects, the projects involved are:

  • Business Logic
  • Data Access
  • Console App

In both BL and DA I have a class called Credit.cs. Both classes are in different namespaces.

When I set a breakpoint on line 235 in BL.Credit.cs then the debugger stops on line 236 in DA.Credit.cs even though there are no breakpoints set. I think this is a bug in Visual Studio.

When I remove the breakpoint in BL is subsequently does not stop in the DA either.

I have submitted a bug if you wish to vote https://connect.microsoft.com/VisualStudio/feedback/details/699804/debugger-stops-on-same-line-in-different-class-where-there-is-no-breakpoint

Here's a workaround for the behavior of breakpoints activating in each class that has the same name even if fully-qualified names are different. After you set a breakpoint, go to the Breakpoints window (Debug | Windows | Breakpoints if it isn't already up). Right-click the breakpoint that's firing in too many same-named classes (eg Project2.Action breaks when you only wanted Project1.Action to have a breakpoint) and selection "Condition." Set the condition value to something like this: this.GetType().FullName == "Project1.Action".

Thereafter, the condition makes it so that execution only breaks on the class with the correct fully-qualified name.

Does it stop by giving you an exception or does it just completely stop the execution of your application? If you don't have the UnHandledExceptionHandler in your code it can look like it just stops but you actually have an exception.

UPDATE: Here is what your Main method should look like to capture unhandled exceptions as try/catch don't always work.

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
        Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

    static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
    {
        throw new NotImplementedException();
    }

    static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
        // You should/MAY see an error right here.
        throw new NotImplementedException();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM