« Update .NET RIA Services Domain Service from Model | Main | Windows 7 RC Just Around the Corner »

Suppressing ValidationException During Debugging

Validation for Silverlight .NET RIA Services throws a ValidationException if during validation it detects invalid data.

image

When your debugging this can cause your debugger to break on the property setter each time a validation error occurs. 

image

After 5 or 6 times of getting that exception and having to switch over and continue will drive you crazy.  Yes, Microsoft is aware that throwing an exception for validation isn’t the best plan, but currently that’s the only option for Silverlight. 

You can turn off breaking on this unhandled exception by adding the type to the list of exceptions and unchecking breaking on user-unhandled exceptions of that type. 

Go to the Debug – > Exceptions menu item and click the Add… button on the right side  In the Type select “Common Language Runtime Exceptions” and input System.ComponentModel.DataAnnotations.ValidationException in the Name field.

image

After you click OK – you should now see it show up in the list as you do below.

image

Uncheck the far right check box “User-Unhandled” and it should look like the following

image

Now simply click “OK” to save the change and go back to your debugging without the interruptions!

Posted on Monday, May 18, 2009 at 01:02AM by Registered CommenterDavid Yack | CommentsPost a Comment

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>