开发者

Error Handling in Silverlight Applications

How is the best way to handle any occuring errors in a Sivlerlight application?

I am not talking about error handling in a development environment开发者_JAVA百科.

But what would be the best way to log errors and look them up for fute reference?


The technique I use is logging to both the server, and client. You do this through one entry point, a Log class with a number of static methods, or a singleton if you prefer. This can then be configured to do just client logging, just server, both or none.

The client log can then be displayed in a non-panic inducing dialog, where the full stacktrace is available in a toggle'able text box. This obviously allows for exceptions to be caught if the web service is down, or broken. It also lets the user copy the stacktrace and email it you if they're particularly irate.

Although server logging (for example with Log4Net) is more powerful as it gives a lot more options for logging including email alerts, it does rely on you being able to find the exception for the particular person, which requires additional search tools or knowledge in the case of the event log.

Having the addition of client logging to fall back on (with server logging on as well) is in my view a worthwhile extra feature.


I typically do not like to rely solely on Silverlight to display the errors in a meaningful way to the client (i.e "Problem loading data..."). Rather I prefer to wrap up the exception and make a call back to my server via a WCF service with an exposed method to accept the Silverlight exception as a parameter. Once on the server, you can log it to the event log, text log, email to the support group etc.

The real key here is to get that exception beck from the client and on to your server to be handled in the best and most communicable manner.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜