The best debugging technique – inverse breakpoint

Hi folks

I found that someone still does not know the technique I’ve been using for ages.

The technique is used when I want to set a breakpoint to debug some problematic code and find it too difficult to start debugging or attach it to the appropriate process

Just put the following snippet into a problematic code. Then recompile and copy resultant exe/dll to the proper location.

System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Break();

First line triggers the UI dialog to attach debugger.
Second line stops as on a breakpoint.

Some authors suggest to use only one of these lines but the behavior is not very reliable. That’s why I use both of them at the time.

This technique is brilliant for debugging things like Visual Studio plugins or custom MSBuild tasks

Advertisements

About mnaoumov

Senior .NET Developer in Readify
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to The best debugging technique – inverse breakpoint

  1. jonathanconway says:

    Nice! Could be used in combination with your copy/paste deployment technique. (https://mnaoumov.wordpress.com/2013/08/21/how-to-reach-unreachable-or-copy-files-to-rdp-part-2/)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s