<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx</link><description>You are making a WinForms app. All is going well, until one day your custom control disappears. In its place you just see a big red cross: What gives? Let us back up to remind ourselves how exceptions work: If your code does something wrong (such as dereferencing</description><dc:language>en</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx#10099668</link><pubDate>Thu, 02 Dec 2010 19:22:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10099668</guid><dc:creator>Erzengel</dc:creator><description>&lt;p&gt;@Mad Martin:&lt;/p&gt;
&lt;p&gt;Go to Tools -&amp;gt; Options, Debugging, and check &amp;quot;Enable Just My Code (Managed Only)&amp;quot;. Then, any function that has handled exceptions you can stick a [System.Diagnostics.DebuggerNonUserCode]. Any handled exception in libraries will be ignored as well.&lt;/p&gt;
&lt;p&gt;I find this an incredibly useful feature to know, and I&amp;#39;m glad Shawn&amp;#39;s getting it out there.&lt;/p&gt;
&lt;p&gt;For info on Just My Code you can check:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/b/zainnab/archive/2010/10/25/understanding-just-my-code.aspx"&gt;blogs.msdn.com/.../understanding-just-my-code.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/h5e30exc.aspx"&gt;msdn.microsoft.com/.../h5e30exc.aspx&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10099668" width="1" height="1"&gt;</description></item><item><title>re: WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx#10098923</link><pubDate>Wed, 01 Dec 2010 11:11:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10098923</guid><dc:creator>Mad Martin</dc:creator><description>&lt;p&gt;While that solution is nice, i find it a nuissance to see every handled exception. For example some functions like file io may throw exceptions, that can be handled very well. If i&amp;#39;d see them all in a large project, it sometimes may be too much. It&amp;#39;s maybe because i avoid exceptions only in the main loop(OnPaint) and handle them in loading, network, database code.&lt;/p&gt;
&lt;p&gt;So i put a try catch block around the contents of the OnPaint method and call Debugger.Break() in the catch area. That lets me see every unhandled exception in the main loop. AFAIK try has only very little overhead, if no exception occurs, so there isn&amp;#39;t a real performance penalty with this method either.&lt;/p&gt;
&lt;p&gt;Martin&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10098923" width="1" height="1"&gt;</description></item><item><title>re: WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx#10096818</link><pubDate>Thu, 25 Nov 2010 23:18:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10096818</guid><dc:creator>Cygon</dc:creator><description>&lt;p&gt;@Timothy: True, there is an exception handling mechanism in WinForms (except that it&amp;#39;s Application.ThreadException, not AppDomain.UnhandledException). So, any idea why they didn&amp;#39;t do it here? To avoid a Hall-of-Mirrors like effect for controls not drawing themselves perhaps?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10096818" width="1" height="1"&gt;</description></item><item><title>re: WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx#10095160</link><pubDate>Mon, 22 Nov 2010 22:41:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10095160</guid><dc:creator>Timothy Fries</dc:creator><description>&lt;p&gt;@Cygon: Just about *everything* done in a Windows Forms app is done via a call from the Windows message loop; and everywhere else the exception is allowed to bubble up (see any button&amp;#39;s Click event for one example). &amp;nbsp;The AppDomain&amp;#39;s unhandled exception handler or, failing that, the CLR&amp;#39;s handler is perfectly capable of catching it and displaying it, even if the exception blows through WndProc.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10095160" width="1" height="1"&gt;</description></item><item><title>re: WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx#10095150</link><pubDate>Mon, 22 Nov 2010 22:12:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10095150</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;I mostly posted this so I have something to link to the next time someone in the forums runs into this issue. &amp;nbsp;Any time I find myself answering the same question for the third or fourth time, I try to turn it into a blog post for future reuse!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10095150" width="1" height="1"&gt;</description></item><item><title>re: WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx#10095118</link><pubDate>Mon, 22 Nov 2010 20:57:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10095118</guid><dc:creator>Christopher Hawkins</dc:creator><description>&lt;p&gt;Also the red cross is a bit less annoying than it jumping into the debugger if you&amp;#39;re using design time tools.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10095118" width="1" height="1"&gt;</description></item><item><title>re: WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx#10095116</link><pubDate>Mon, 22 Nov 2010 20:54:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10095116</guid><dc:creator>Cygon</dc:creator><description>&lt;p&gt;I think the reason probably is because OnPaint() is being called from within the Windows message loop (or more specifically, the WndProc callback) and WinForms can&amp;#39;t just let the exception travel upwards into the code that called WndProc.&lt;/p&gt;
&lt;p&gt;I wonder why they don&amp;#39;t just remember the exception and destroy the window right after the message has been processed - and then rethrow the exception out of Application.Run() / Form.ShowDialog() or whatever is running the message loop at that time.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10095116" width="1" height="1"&gt;</description></item><item><title>re: WinForms and the big red 'X' of doom</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/11/22/winforms-and-the-big-red-x-of-doom.aspx#10095115</link><pubDate>Mon, 22 Nov 2010 20:52:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10095115</guid><dc:creator>Michael Cummings</dc:creator><description>&lt;p&gt;I&amp;#39;m not as interested in the content of the post as much as to *why* you posted this? What cool new Xna features that Shawn is working on requires a Winform Custom Control?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10095115" width="1" height="1"&gt;</description></item></channel></rss>