Awhile back, I blogged about how Silverlight uses Validation Exceptions, which can cause the debugger to break.  I showed how to prevent that from happening, but the solution was less than ideal.

Someone named rlodina commented on the post:

What about manual adding:
System.ComponentModel.DataAnnotation.ValidationException
in this list.

This comment has been sitting in my inbox for about a week, and I had wanted to follow up on this.  Well good gosh, this is easy and it works like a charm.  You can in fact tell VS to only ignore ValidationException instances, while still breaking on everything else.  Here’s how.

  1. Click on Debug->Exceptions (Ctrl+D, E for your keyboard folks)
  2. Click on Add…
  3. Select the Type as “Common Language Runtime Exceptions”
  4. Type the name as System.ComponentModel.DataAnnotations.ValidationException and click OK.
  5. You’ll now see this exception in the list.  Uncheck “User-unhandled just for this exception, and click OK.

image

This lets you keep all of the other exceptions turned on, but Visual Studio will no longer break when Silverlight hits a ValidationException.  Like I said, it works like a charm.  Thanks rlodina! :-)