Tuesday, December 22, 2009

Catch Those Pesky WPF Data Binding Errors!

After months of changes to a WPF app, today I noticed that the Visual Studio output windows was frought with warnings about "System.Windows.Data Error" when debugging the application.

Aside from a poorly performing app, on principal I dispise any uncaught problems in an application, wanrings, errors or otherwise. Leaving it up to the runtime to deal with misbehaving code is a sign of a lazy developer.

After looking into it more deeply, I remembered an off-handed article I read some time back about how WPF has implemented XAML data binding errors as warnings rather than hard exceptions. While there's no way to change this aspect of the runtime that I know of, there are a few helpful hints here: http://beacosta.com/blog/?p=52

A note to developers: fewer exceptions (caught or uncaught) in your code means a faster performing application...period. The less the runtime has to babysit what your app is doing, the more time your application has to do what it's supposed to do.

Serves me right for disregarding the optup window for so long.

2 comments:

  1. Beter late than never, but check http://jasonbock.net/jb/Default.aspx?blog=entry.0f221e047de740ee90722b248933a28d for a solution to transform data binding errors into native exceptions.

    ReplyDelete
  2. Jeroen, thanks for the link. Awesome article! Now I just have to retrofit my 'unhandled exception handler and testing will be so much more concise. Cheers.

    ReplyDelete