i followed the RIA Overview PDF and added a shared.cs file to my Project in which i validate some other fields which works fine.
but if i add something like:
[Required]
[StringLength(3, MinimumLength=3)]
public string plz;
to the metadata i get the error: ValidationException was unhandled by User Code.
I thought it would just display the user that field plz hast to be at least 3 and at max 3 characters long.
How and where do i have to handle the Exception in my code?
What is happening is that the Debugger is set by default to catch uncaught user exceptions, and if you run from the debugger when validation exceptions are thrown, you break to the debugger.
We're working with the validation and data-binding folks to work out a better story to avoid this exception being unhandled.
But your life will be simpler in the meantime if you use the Debug | Exceptions menu and uncheck "User-unhandled". This does not prevent the app from seeing these exceptions. It just stops the debugger from breaking when they occur.
callmeknud
Member
16 Points
84 Posts
RIA CustomValidation(...) - [Required] [StringLength(3, MinimumLength=2)] -> ValidationException...
Apr 01, 2009 01:02 PM | LINK
Hello,
i followed the RIA Overview PDF and added a shared.cs file to my Project in which i validate some other fields which works fine.
but if i add something like:
[Required]
[StringLength(3, MinimumLength=3)]
public string plz;
to the metadata i get the error: ValidationException was unhandled by User Code.
I thought it would just display the user that field plz hast to be at least 3 and at max 3 characters long.
How and where do i have to handle the Exception in my code?
thanks!
lee_sl
Contributor
4222 Points
864 Posts
Re: RIA CustomValidation(...) - [Required] [StringLength(3, MinimumLength=2)] -> ValidationExcept...
Apr 01, 2009 01:44 PM | LINK
In the debug menu in VS uncheck clr exceptions and run it
Available for consulting in Dallas, TX
http://leeontech.wordpress.com/
roncain
Participant
902 Points
177 Posts
Microsoft
Re: RIA CustomValidation(...) - [Required] [StringLength(3, MinimumLength=2)] -> ValidationExcept...
Apr 01, 2009 04:20 PM | LINK
Yes, that is the right thing to do for now.
What is happening is that the Debugger is set by default to catch uncaught user exceptions, and if you run from the debugger when validation exceptions are thrown, you break to the debugger.
We're working with the validation and data-binding folks to work out a better story to avoid this exception being unhandled.
But your life will be simpler in the meantime if you use the Debug | Exceptions menu and uncheck "User-unhandled". This does not prevent the app from seeing these exceptions. It just stops the debugger from breaking when they occur.
callmeknud
Member
16 Points
84 Posts
Re: Re: RIA CustomValidation(...) - [Required] [StringLength(3, MinimumLength=2)] -> ValidationEx...
Apr 02, 2009 06:29 AM | LINK
Thank you!
BenHayat
Participant
1097 Points
656 Posts
Re: Re: RIA CustomValidation(...) - [Required] [StringLength(3, MinimumLength=2)] -> ValidationEx...
Apr 02, 2009 01:03 PM | LINK
Hi, if your question was answered, please mark it as "Answered", so others can take advantage of resolved questions.
Thanks!
Best Regards;
..Ben
sethian
Member
44 Points
58 Posts
Re: Re: RIA CustomValidation(...) - [Required] [StringLength(3, MinimumLength=2)] -> ValidationEx...
Jul 24, 2009 03:23 PM | LINK
Going into Debug->Exceptions and simply clearing the clr check box is not the best work around for this problem.
You should add the exception:
System.ComponentModel.DataAnnotations.ValidationException
and clear the User-unhandled for only that particular one (since that's what's getting thrown).
Otherwise all user-unhandled clr exceptions will not cause a break in the debugger, and you won't know when your code is throwing an exception.