Controlling the Debugger

Besides the Debug class, the System.Diagnostics namespace has a Debugger class, whose static methods are used to control the debugger. Arguably, the most useful of all its methods is Break, which causes the code to break in the debugger at the point of the call. This functionality is often used to debug a program’s startup path, in cases where it’s rather inconvenient to have a debugger attached already. For example, some other process may launch your program without leaving you a chance to attach a debugger.

Image File Execution Options

In fact, the problem of debugging a startup path has been around since the early days of Windows. It’s not really a problem, though. The designers of the loader that is used to run ...

Get C# 4.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.