Handle exceptions from WS
I've WS client written in C#. Is there any way I can handle all exceptions in one place? Now WS methods are executed in many places so I开发者_StackOverflow have to write many try...catch to handle them all.
Thanks
use
AppDomain.CurrentDomain.UnhandledException
before creating winform, you need to add this line
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Use svcutil.exe (In Visual Studio: "Add Service Reference") to generate a WCF client, even if it is just a plain old (asmx) web service. Then you can inject your own implementation of the IErrorHandler interface. In this case you just need to provide an implementation of IErrorHandler.HandleError since the ProvideFault method would only be used on the service side.
精彩评论