How can I use the FaultContract attribute with RIA Services so that I’ll be able to pass additional information as part of an exception to Silverlight?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So I went hunting though the decompiled RIA Services code. It doesn’t seem like it’s possible to significantly alter the error info that is sent to the client.
You are able to override the
OnError()method in your DomainService, but this doesn’t allow you to pass arbitrary information back, even if it’s a custom exception type.The reason is buried inside the exception handling of the
DomainServices.Hosting.QueryProcessorclass.If an unhandled exception occurs in a domain operation, it bubbles back and then a FaultException() is ultimately thrown (which WCF natively handles).
Unfortuantely, the
DomainServiceFaultclass is very lightweight… It only has a few properties…and these are populated in the
ServiceUtility.CreateFaultExceotion()like so:It’s worth noting in the case of an Exception, rather than validation errors, the
OperationErrorsare not populated.So the upshot of all of this is that I don’t believe it’s possible to wrap or attach custom exception information to the DomainService error handler (which is really unfortunate).