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.

Note: 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 ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.