Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



Breaking on exceptions reveals the ugly truth of your application

So, you wanna know how good or bad your application really is?  Setup your IDE to break on all thrown exceptions.  This will really let you know how good or bad your application is.  This is also great way to find a pesky unhandled exception.

To tell your IDE to break on thrown exceptions do the following.
Click the Debug toolbar item
Click the Exceptions menu item (Ctrl+Alt+E)
Check the check box for 'Thrown' for the Common Language Runtime Exceptions

ExceptionDialog

After you turn this option on you just may be surprised how many unhandled and swallowed exceptions your application has.

Have fun, and use with caution.  You may not like the results you get.

Till next time,



Comments

Peter Ritchie said:

I don't recommend this for XML Web Services (unless you're very patient).  The way XML Serialization decides that it needs to generate an assembly for the serialization of a type is that when it tries to first access the assembly it gets a file not found exception.  Of course, it needs to regenerate those assemblies after you do a build, so when you debug a web service to spent some initial time skipping pass several handled exceptions before you even get to your code.

This also fires some extraneous BindingFailure MDA alerts when you turn on the BindingFailure MDA.  Very much a PITA.

# February 4, 2008 10:30 AM

Derik Whittaker said:

@Peter,

This is good to know.  I have not actually done this when anything that has web services.  

Thanks,

# February 4, 2008 10:39 AM

Wojciech Gebczyk said:

Yes, it's very convenient way to discover bad code :-)

Additionally:

Tools>Options | Debugging>General option "Enable Just My Code"

If you check it then ony "yours" exceptions will be handled, otherwise ALL exceptions including framework ones.

It's true, unfortunatelly XML Serializer, WebServices, WCF seems to be using exceptions as flow controllers :/

# February 4, 2008 5:46 PM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# February 5, 2008 6:13 AM

» Daily Bits - February 5, 2008 Alvin Ashcraft’s Daily Geek Bits: Daily links, development, gadgets and raising rugrats. said:

Pingback from  » Daily Bits - February 5, 2008 Alvin Ashcraft’s Daily Geek Bits: Daily links, development, gadgets and raising rugrats.

# February 5, 2008 8:28 AM

Dennison Uy said:

Neat stuff. The VS debugger is such a powerful tool. Aside from this, it is useful to have an exception trapper in your main thread that will trap all exceptions of member objects and variables and log them.

# February 20, 2008 6:01 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Red-Gate!