Search
More About This Website

All information is provided "AS IS" with no warranties, and confers no rights

Login
« Lessons learned from my iPhone experiment | Main | Kicking the tires on SQL Azure »
Thursday
Sep102009

RIA Services – Finding the InnerException

One of the challenges I’ve run into with using RIA services is that sometimes you get back a message saying check InnerException only to find it is null. 

 

In the following example, I had deleted some data and submitted changes.  I set a break point on the server side in the delete method so I knew that it’s getting called and ran ok.  Back on the client side I would see an exception when checking the results of the submit operation as you can see in the following example.  The catch is notice that the message tells me to check the InnerException which is null!

image

 

While I clearly believe this is a bug and have reported it, I wanted to share how I track down what the real error is.  The quickest path I have found is to override the PersistChangeSet method on the server DomainService.  As you can see in the following example all I do is capture the error and I can set a break point.  You can now quickly determine what the error is.  If you want, this is also where you could “fixup” the exception to pass back a more meaningful message.

 

Update: From Nikhil - He suggests overriding Submit which is a good sugestion, the idea is you need to catch the error server side in order to know the "why" so there's two places you can hook into if you want.

 

image

Reader Comments (4)

I'd recommend overriding Submit rather than PersistChangeSet.

This one is relatively minor, but I'd suggest using throw; rather than throw ex; so the stack trace on the exception stays intact.

September 10, 2009 | Unregistered CommenterNikhil Kothari

Thanks Nikhil - I added a note to the post in case people don't read down thru the comments.

September 10, 2009 | Registered CommenterDavid Yack

Keep in mind that the current error handling for non-verification based exceptions is in the DataServiceFactory AKA DataService.axd which is the piece that is being chucked in the next version of RIA Services in favor of ADO.NET Data Services. I suppose that means that Nikhil gets to "fix" this bug using his delete key.

September 10, 2009 | Unregistered CommenterColin Blair

David,Excelent article.
You have to mention that <customErrors mode="Off"/> needs to be in the Web.Config file in the <System.Web> section otherwise You won't get the innerexception. I had a hard time trying to get the inner exception until I realized this.

October 11, 2009 | Unregistered CommenterWilson Guerra

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>