System.Diagnostics.Debugger.Debug() stopped working

后端 未结 4 1845
时光取名叫无心
时光取名叫无心 2020-12-10 13:42

I\'m working on a program which uses the System.Diagnostics.Debugger.Break() method to allow the user to set a breakpoint from the command-line. This has worked fine for ma

相关标签:
4条回答
  • 2020-12-10 13:46

    I was using debugger.launch() method and it stopped working suddenly. using

    if (Debugger.IsAttached == false) Debugger.Launch(); 
    

    also did not bring up the debugger. I tried resetting my visual studio settings and it worked!

    0 讨论(0)
  • 2020-12-10 13:51

    Extracted from here (MSDN) the following note:

    Starting with net_v40_long, the runtime no longer exercises tight control of launching the debugger for the M:System.Diagnostics.Debugger.Break method, but instead reports an error to the Windows Error Reporting (WER) subsystem. WER provides many settings to customize the problem reporting experience, so a lot of factors will influence the way WER responds to an error such as operating system version, process, session, user, machine and domain. If you're having unexpected results when calling the M:System.Diagnostics.Debugger.Break method, check the WER settings on your machine. For more information on how to customize WER, see WER Settingshttps://msdn.microsoft.com/library/windows/desktop/bb513638.aspx. If you want to ensure the debugger is launched regardless of the WER settings, be sure to call the M:System.Diagnostics.Debugger.Launch method instead.

    I think it explains the behavior detected.

    0 讨论(0)
  • 2020-12-10 13:56

    Are you using VS 2008 SP1? I had a lot of problems around debugging in that release, and all of them were solved by this Microsoft patch.

    Breakpoints put in loops or in recursive functions are not hit in all processes at each iteration. Frequently, some processes may pass through many iterations of a loop, ignoring the breakpoint, before a process is stopped.

    Breakpoints are hit, but they are not visible when you debug multiple processes in the Visual Studio debugger.

    There are a few other debugger-related problems also fixed.

    0 讨论(0)
  • 2020-12-10 14:04

    I finally figured out what was happening. For some reason, something changed on my machine so that just calling Debugger.Debug wasn't sufficient anymore (still don't understand what changed). In any case, I can now cause the debugger to come up by using:

    if (Debugger.IsAttached == false) Debugger.Launch();
    
    0 讨论(0)
提交回复
热议问题