I have some code that uses Debug.Assert & Debug.Trace. When VS 2010 is attached, I can see the assert & trace messages in my output window. However, when VS is not attached, I don't see anything when using the DebugView utility and my application doesn't
show a dialog box nor break into a debugger.
My dream would be to either display a dialog to developers like myself with an assert is raised or, failing that, redirect to an error page. Writing to a log file would be next best. As it stands now, the only time I can get any trace or assert output
is when the debugger is attached, and it is easy to miss either of these messages.
Thank you very much for your reply. I realize that Debug.Assert does not call OutputDebugString; I didn't necessarily expect the output of Debug.Assert to appear in DebugView, although I did expect the output of Debug.Trace to appear there (but it is not).
In the case of Debug.Assert, I'm trying to find a way to break into a debugger, display a dialog box, or otherwise aggressively get in the face of the developer.
Notre_Poubel...
Member
12 Points
23 Posts
Viewing asserts
Feb 09, 2012 09:00 PM|LINK
Hi,
I have some code that uses Debug.Assert & Debug.Trace. When VS 2010 is attached, I can see the assert & trace messages in my output window. However, when VS is not attached, I don't see anything when using the DebugView utility and my application doesn't show a dialog box nor break into a debugger.
I've read the there was some changes to the .NET 4, such that Debug.Trace no longer outputs to trace listeners (https://connect.microsoft.com/VisualStudio/feedback/details/457063/outputdebugstring-doesnt-work-in-the-debugger-vs-2010-pro-beta-1-c). I also read about some optional configuration options to conditionally display a dialog box, when there's an assert (http://msdn.microsoft.com/en-us/library/ty5e4c4h.aspx). I tried setting the assertuienabled property to true, but I don't see any dialogs. I then set it to false and set the logfilename to a file in a path I would expect to be writable, but no file is written there.
I ran across an article (http://gregbeech.com/blog/how-to-integrate-debug-assert-with-your-asp-net-web-application) that describes how to use Debug.Assert with ASP.NET, but the article is pretty old and seems like it might have the same problems as I'm having.
My dream would be to either display a dialog to developers like myself with an assert is raised or, failing that, redirect to an error page. Writing to a log file would be next best. As it stands now, the only time I can get any trace or assert output is when the debugger is attached, and it is easy to miss either of these messages.
Thanks,
Notre
cts-mgraham
Contributor
3318 Points
642 Posts
Microsoft
Re: Viewing asserts
Mar 17, 2012 12:06 PM|LINK
DebugView monitors calls to OutputDebugString API =>
Under Windows 2000, XP, Server 2003 and Vista DebugView will capture:
Debug.Assert in .NET does not call OutputDebugString. Debug.WriteLine writes to OutputDebugString.
Notre_Poubel...
Member
12 Points
23 Posts
Re: Viewing asserts
Mar 26, 2012 04:40 PM|LINK
Hi Michael,
Thank you very much for your reply. I realize that Debug.Assert does not call OutputDebugString; I didn't necessarily expect the output of Debug.Assert to appear in DebugView, although I did expect the output of Debug.Trace to appear there (but it is not). In the case of Debug.Assert, I'm trying to find a way to break into a debugger, display a dialog box, or otherwise aggressively get in the face of the developer.
Thanks,
Notre