views:

310

answers:

1

I am currently trying to implement the built-in Silverlight 3 validation against objects that are accessed via a web service. I have tried to follow the examples listed on SilverLight.net (Jesse Liberty's tutorial) and have had no luck. In fact, I could not get the tutorial to work after I downloaded it unless I started it without debugging.

Currently my code looks like this

[DataContract]
    public class Email
    {        
        [DataMember]
        public string EMailID;
        [DataMember]
        public string EMailTypeID;
        [DataMember]
        public string EMailTypeName;
        [DataMember]
        public string UserID;
        [DataMember]
        public string EMailAddress;
        [DataMember]
        public string ActiveRecordFlag;
        [DataMember]
        public string Created;
        [DataMember]
        public string Modified;        
    }

I tried the INotifyChange changes, all to no avail. Has anyone done this before, or seen a tutorial on how to use objects that are accessed via web services with the built in validation?

Thanks ~Steve

A: 

I had a similar problem with Jesse Liberty's tutorial. Like you said, it works if you run it without debugging. If you had the same problem I had then you can try my solution.

The problem was that a validation check against a field with an invalid input throws a ValidationException that the debugger picks up. It shouldn't do this since it is the validation framework that should handle this exception automatically and show the result on screen.

To get around this, you have to add an exception to visual studio to get it to ignore the exception. To do this, in top menu bar, select 'Debug' and then select 'Exceptions...'. In the window that appears click the 'Add...' button. Select 'Common Language Runtime Exceptions' from the 'Type' combo box and enter 'System.ComponentModel.DataAnnotations.ValidationException' in the 'Name' field and click OK. The tutorial should work now. Hopefully it should be enough to follow on from there like I did

Fahd