.Net Debugging Classes


The System.Diagnostics namespace contains five groups of classes that can help an programmer to debug and trace .NET applications. This five groups of classes have following uses :

  1. debugging
  2. tracing
  3. using of Windows event log
  4. performance monitoring
  5. process controlling

This article will review the Debugger and Debug classes contained by first group of System.Diagnostics namespace.

            The Debugger class enables communication with a debugger application. This class provides some useful low-level debugging APIs such as:

  • Debugger.Break() – causes the application to break under the debugger when executed.
  • Debugger.Log() – post informations to the attached debugger.If no debugger  is present ,the result is efectively nothing.
  • Debugger.Launch() – this launches a debugger if one is not attached.
  • Debugger.IsAttached – this detects if a debugger is attached.

         Althought the Debugger class is very useful, there are times when we need more granularity. In those cases we can use Debug class.
Assert method of Debug class evaluates a condition and if condition isn’t true , it will break into the debugger automatically.

Debug.Assert(MyObject != null, "MyObject is null");

If the condition of Assert method isn’t true, an message box with “Abort”, “Retry” and “Ignore” buttons will be prompted on the screen.
Similar to Assert is the Fail method, which simply break at the offending line of code and output a failure message.

if(MyObject == null)
Debug.Fail("MyObject is null");

Write, WriteLine, WriteIf and WriteLineIf methods are used to send messages to Output window.

Debug.WriteIf(var == null, "Variable var is null");


Besides these classes, .NET Framework provide debug attributes to allow developers to control the behavior of their applications.  Some debug attributes :

  • DebuggerBrowsable attribute – determines if and how a member is displayed in the debugger variable windows
  • DebuggerDisplay attribute – controls how a class or field is displayed in the debugger variable windows
  • DebuggerHidden attribute – it stops a breakpoint from being set inside anything that it decorates

Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.