Best way to catch a WCF exception in Silverlight?

前端 未结 9 1107
悲哀的现实
悲哀的现实 2020-12-31 06:43

I have a Silverlight 2 application that is consuming a WCF service. As such, it uses asynchronous callbacks for all the calls to the methods of the service. If the service

9条回答
  •  悲哀的现实
    2020-12-31 07:07

    You can forget about Application_UnhandledException on asyn client callbacks, reason why:

    Application_UnhandledException only exceptions fired on the UI thread can be caught by Application.UnhandledExceptions

    This means... not called at all for a WCF async call :-).

    Check detailed response from MSFT

    http://silverlight.net/forums/t/21828.aspx

    Hello, only exceptions fired on the UI thread can be caught by Application.UnhandledExceptions. It can't catch exceptions from other threads. You can try this to trouble shoot the issue: In Visual Studio, from the Debug menu, choose Exceptions. Then check "Common Language Runtime Exceptions". This will make the debugger stop whenever an exception is thrown. But note this may be quite annoying sometimes since even if an exception is already caught. You can use the CheckBoxes to filter the exceptions you want to catch.

    Good news in my case is that handling the error message just in the clietn service call back is enough if you are not debugging.

    Thanks

    Braulio
    

提交回复
热议问题