Thursday, October 7, 2010

Silverlight debugging: Telling Visual Studio not to break on ValidationException

I found it was annoying that I would get thrown into the debugger every time a ValidationException was thrown in the Silverlight field validation logic.  This can be fixed by telling VS to ignore this particular exception:

VS 2010 already has the ValidationException in the Exceptions list, but if yours doesn’t or you are using VS 2008, you can follow these instructions to manually add it:

  1. Click on Debug->Exceptions (Ctrl+D, E)
  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.


This lets you keep all of the other exceptions turned on, but Visual Studio will no longer break when Silverlight hits a ValidationException.

No comments: