tags:

views:

134

answers:

2

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 many weeks now. However, when I was working on fixing a unit test today, I tried to use the debug switch from the command-line, and it didn't work.

Here's what I've tried:

  • I've confirmed that the Debug() method is really being called (by putting a System.Console.WriteLine() after it)
  • I've confirmed that the build is still in Debug
  • I've done a clean build
  • I've restarted Product Studio

A quick Google search didn't reveal anything, and the API documentation for .Net doesn't mention anything about this function not performing correctly. So... any ideas?

A: 

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.

Michael Petrotta
Sorry... after installing the patch, I'm still seeing the problem. :-(
Andrew Miner
A: 

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();
Andrew Miner