Debugging Microsoft .NET 2.0 Applications

Author: Dino Esposito
All Stack Overflow 11


by anonymous   2017-08-20

Personally, I rarely use the Debug class at all for any of my programming. I've read a lot of comments and suggestions, such as those by John Robbins (author of Debugging .NET 2.0 Applications and the Bugslayer columns) about why you should be asserting proactively - especially parameters for methods.

The problem I have is this - say I was to write code like this:

Public Sub Test(source As Object)

  Debug.Assert(source IsNot Nothing, "source is Nothing")

  ' Do something....
End Sub

This works well during development with debug builds, but I end up doing this anyway:

Public Sub Test(source As Object)

  If source IsNot Nothing Then

  ' Do something....

  End If
End Sub

If there's a chance for 'source' to be nothing, then I'm going to do an 'If' check on it anyway. I'm not going to leave the assert call in the release build.

The other reason I don't use the Debug class is that I write a lot of unit tests. Doing so has led me to covering a lot of code paths, thus having a Debug.Assert in my code is not required.

As for debug logging, then I simply use Trace calls and SysInternals DebugView or text files to log the output of trace calls.

I would love to hear from others on this topic, since I'm also interested in knowing how they might be using the Debug class during development. It's an area I don't have much experience in, so I'm eager to learn.

by anonymous   2017-08-20

There is no easy way of doing that. The only working approach I've seen is adding code to your application that will attach external debugger to itself and read stack information. John Robbins is showing this is his book using modified sources of MDBG.

by Michael Burr   2017-08-20

Since you asked for pointers to books... As far as Windows debugging goes, John Robbins has several editions of a good book on Windows debugging:

Debugging Applications for Microsoft .NET and Microsoft Windows

Note that the most recent edition (Debugging Microsoft .NET 2.0 Applications) is .NET only, so you might want an older one (like in the first link) if you want native code debugging (it covers both .NET and native).