Josh
Josh

Reputation: 10604

Silverlight logging of errors

What is the correct way of handling errors on the client side of Silverlight applications? I tried building a service endpoint that would receive details about the error and then would write that string to the database. The problem is, the error's text exceeds the maximum byte length, so I can't send the exception message and stacktrace. What would be a better way of handling errors that end up at the client side?

Upvotes: 2

Views: 3958

Answers (4)

Grigori Melnik
Grigori Melnik

Reputation: 4107

Take a look at the new Silverlight Integration Pack for Enterprise Library from Microsoft patterns & practices. It provides plumbing for both logging (client-side and via a remote service) and exception handling with flexible configuration of policies via config or programmatically.

Upvotes: 0

user20358
user20358

Reputation: 14736

You should not be considering logging of error messages via a service. What if the error that you want to log is related to the service itself? Maybe the server that hosts all dependant services (including the error logging service) is not reachable or down. client errors should be logged on the client side and periodically flushed to the server when connectivity to service is available.

Thats what I would do...

Upvotes: 0

slugster
slugster

Reputation: 49974

If you find you message is too long to send to your logging web service then try setting your binding properties such as maxBufferSize and maxStringContentLength to appropriately large values. They default to 16KB, personally i have set mine to 2147483647 (which is int.MaxValue).

Obviously you cannot send the raw exception straight to the logging web service (exceptions are not serializable), what i did was write a function that takes an exception and walks it, translating it into a WCF friendly structure that can then be passed to my logging end point. Of course you need to ensure that if this fails you have a backup plan, like maybe logging it to isolated storage if you are running in browser, or logging it to the user's file system if you are running elevated OOB.

Upvotes: 0

Gabe
Gabe

Reputation: 50493

Try handling faults...I used this pattern from MSDN

http://msdn.microsoft.com/en-us/library/dd470096%28VS.96%29.aspx

Upvotes: 1

Related Questions