Skip to main content

Microsoft Silverlight

Answered Question Visual Studio throws "unhandled error" on Jesse Liberty validation example project WHY?RSS Feed

(0)

TBink
TBink

Member

Member

254 points

188 Posts

Visual Studio throws "unhandled error" on Jesse Liberty validation example project WHY?

I setup Jesse Liberty's mini-tutorial "Silverlight Validation in Detail" as a visual studio solution.  Absolutely verbatim.  Yet when I ran it an an unhandled error tripped up the debugger in the get/set for ISBN10 (at line 36 ... the debugger opted out).

** I'd very much appreciate a note from someone at MS and/or Visual Studio if this work around is required or if I've done something wrong... that makes this work around unnecessary ** 

 

 private string isbn10;
  25:     public string ISBN10
  26:     {
  27:       get
  28:       {
  29:         return isbn10;
  30:       }
  31:       set
  32:       {
  33:          
  34:         if ( value.Length != 10 )
  35:         {
  36:           throw new ArgumentException( "Must be exactly 10 integers long" );
  37:         }
  38:  
  39:         char[] isbnAsArray = value.ToCharArray();
  40:  
  41:         foreach ( char c in isbnAsArray )





I found a solution here: 
http://silverlightfeeds.com/post/958/Not_Breaking_on_ValidationException_take_2.aspx  
by Jeff Handley

  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.
---------- 

This works like a charm... but I'm completely puzzled by why none of the examples I've seen mention this. Is there a patch for Visual Studio that I'm missing? How could Jesse have missed this (and everyone else who's written examples

VERY puzzled
tom
(and many thanks to Jeff for providing the solution"

TBink
TBink

Member

Member

254 points

188 Posts

Answered Question

Re: Visual Studio throws "unhandled error" on Jesse Liberty validation example project WHY?

Here's the full text

Not Breaking on ValidationException (take 2)

by Jeff Handley via Jeff Handley on 8/8/2009 2:44:39 AM

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! :-)

markpaul
markpaul

Member

Member

6 points

4 Posts

Fix does not work? Do ineed any library, dll, etc?

Hi guys,

I'm having similar issues with Jesse Liberty's tutorial code here:
http://silverlight.net/learn/videos/silverlight-videos/implementing-password-validation/

On running the program, and by not entering a valid email for the id field, Visual Studio breaks with the exception

"System.ArgumentException was unhandled by user code
Message="Email address not valid."
StackTrace:
at PasswordValidation.Membership.set_Id(String value)
InnerException:


I have done the fix by adding the "System.ComponentModel.DataAnnotation.ValidationException" to the “Common Language Runtime Exceptions” exceptions list and Uncheck “User-unhandled" just fot it, but it still happens.

Am i missing something very basic here? Do i need to add a reference to any exception library DLL or something?

Cheers,
Mark

markpaul
markpaul

Member

Member

6 points

4 Posts

Re: Fix does not work? Do ineed any library, dll, etc?

What i noticed is that this issue is only when you hit debug inside visual studio as that is what halts program, When you open the html file with the XAP in it individually it works well. So the problem is still in the VS level and the fix does not seem to work for me for some reason

rlodina
rlodina

Member

Member

14 points

2 Posts

Re: Fix does not work? Do ineed any library, dll, etc?

Hi Paul.

markpaul:
I have done the fix by adding the "System.ComponentModel.DataAnnotation.ValidationException" to the “Common Language Runtime Exceptions” exceptions list and Uncheck “User-unhandled" just fot it, but it still happens.


There is a mistake (sorry) in my comment on Jeff blog.

Please use: System.ComponentModel.DataAnnotations.ValidationException


Good luck.
rlodina

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities