Thursday, November 12, 2009

Preventing Dialogs or Trace.Fail

The System.Diagnostics provide a very nice infrastructure for logging. When you start an app, by default a DefaultTraceListener is added to the Debug.Listeners collection. The problem is that the DefaultTraceListener instance has the property AssertUiEnabled set to true. This will popup a nice message box, in case for example of this statement






In winforms or console apps this is quite nice. Especially the possibility to attempt a retry ...



In case you need to disable this dialog: for a wpf app, for asp.net, for a wcf service... then you simply need to set the AssertUiEnabled property to false. In addition you can wire your own outputs...


1 comments:

  1. Scott has posted a very nice explanation...
    http://www.hanselman.com/blog/CommentView.aspx?guid=e4dc1e1c-3aca-4d4a-8b09-255a3e7a1e14
    ReplyDelete

Post a comment