views:

1463

answers:

3

Hello,

I got a dataform partially working with RIA services (I can fetch and edit data).

The problem is that I added validation to my RIA service fields. Ex: from my metadata.cs file

[StringLength ( 50, ErrorMessage= "bad data dude!" , MinimumLength=4)] public string Title;

In the dataform, when a user enters data violating the above rule, an exception is thrown saying "bad data dude!" which is sort of OK. The problem is that I would like the data form to show this message in the error summary?

What am I doing wrong?

A: 

FYI: Also, just found out this only occurs when debugging with Visual Studio.

I can get everything working correctly if I run without debugging (Ctrl + F5)

A better solution exists?

vidalsasoon
+2  A: 

Visual Studio breaks because it sees an error it believes is not handled. If you just continue the program the error will be handled and the failed validation will show as expected.

You can tell VS not to stop on an user unhanded ValidationException using the Debug/Exceptions dialog in VS.

Maurice
the correct answer
thepaulpage
+1  A: 

Hopefully they will add System.ComponentModel.DataAnnotations.ValidationException as an option in Debug->Exceptions. Right now it looks like you have to do it at more of a root level http://blog.jeffhandley.com/archive/2009/04/01/184.aspx