<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Tech Tip: I Break for Exceptions</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Tech Tip: I Break for Exceptions</description>
  <pubDate>Sat, 25 May 2013 09:09:08 -700</pubDate>
  <lastBuildDate>Wed, 06 Jun 2007 16:19:43 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=74</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Tech Tip: I Break for Exceptions : Level 200 DevForce Express June...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=74&amp;PID=152#152</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 74<br /><strong>Posted:</strong> 06-Jun-2007 at 4:19pm<br /><br /><P =Questi&#111;n style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3><strong><EM>Level 200 <BR>DevForce Express</EM></strong></FONT></P><P =Questi&#111;n style="MARGIN: 0in 0in 0pt"><strong><EM><FONT face="Times New Roman" size=3>June 7, 2006</FONT></EM></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>We must be able to pause execution of our application to debug it effectively. We use breakpoints most of the time to tell the debugger where to stop. </FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>We usually want the debugger to pause when our application throws an exception. The debugger breaks on an exception by default unless our code catches that exception. In other words, the debugger <B>will not stop</B> if the line that throws the exception is wrapped in a Try/Catch block. Execution continues and we may be unable to discover where or even if the exception was thrown.</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>We can configure the Visual Studio debugger to break whenever an exception is thrown, even if it is caught in a Try/Catch block. Press <B>Ctrl-Alt- E</B>; Visual Studio presents the <B>Exceptions</B> dialog. The dialog displays a tree of exceptions, categorized by general type.</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>Each exception (or exception type) is paired with two checkbox columns. The column titled "Thrown" is unchecked by default; if checked, the debugger should pause whenever the exception is thrown. The second, "User-unhandled", is typically checked and tells the debugger to pause if the exception is not handled (e.g., is not caught in a Try/Catch block).</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>We can tell the debugger to break on a broad category of exceptions (such as break on all Common Language Runtime Exceptions), or a category of exceptions from a namespace (such as any System.IO exception), or on a specific exception (like System.IO.IOException) by checking the "Thrown" checkbox as shown in Figure 1.</FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 13pt"><B><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Helvetica; mso-bidi-font-size: 12.0pt">Figure 1:</SPAN></B></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 13pt"><B><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Helvetica; mso-bidi-font-size: 12.0pt"></SPAN></B>&nbsp;</P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 13pt"><B><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Helvetica; mso-bidi-font-size: 12.0pt"><img src="http://www.ideablade.com/Forum/uploads/20070606_191832_SNAG-0033.jpg" height="351" width="664" border="0" /></SPAN></B></P><B><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Helvetica; mso-bidi-font-size: 12.0pt"></SPAN></B><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Helvetica"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>We can add other exceptions to this list - such as DevForce or our own custom exception - by clicking the "Add" button. In the ensuing <B>New Exception</B> dialog (Figure 2):&nbsp;</FONT></P><UL style="MARGIN-TOP: 0in" =disc><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=2>Set the <B>Type</B> to Common Language Runtime Exceptions </FONT></LI><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=2>Enter the fully qualified name (ex: MyNamespace.MyException) </FONT></LI><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=2>Click <B>OK</B> </FONT></LI></UL><DIV></DIV><P><FONT face="Times New Roman" size=2><img src="http://www.ideablade.com/Forum/uploads/20070606_191917_SNAG-0034.jpg" height="168" width="569" border="0" /></FONT></P><FONT face="Times New Roman" size=2><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><SPAN style="mso-bidi-font-size: 9.0pt">Finally, the debugger will not stop for an exception thrown in a method with a debugger directive attribute such as System.Diagnostics.DebuggerStepThrough. You will have to remove the attribute or comment it out to debug into that method.<o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 13pt"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Helvetica"><o:p>&nbsp;</o:p></SPAN></P><P></FONT></o:p></SPAN>&nbsp;</P>]]>
   </description>
   <pubDate>Wed, 06 Jun 2007 16:19:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=74&amp;PID=152#152</guid>
  </item> 
 </channel>
</rss>