开发者

Silverlight logging of errors

开发者 https://www.devze.com 2023-01-21 21:56 出处:网络
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 abou开发者_高级运维t the error and then would w

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 abou开发者_高级运维t 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?


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

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


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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号