arek
arek

Reputation: 1332

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 have to write many try...catch to handle them all.

Thanks

Upvotes: 3

Views: 140

Answers (2)

Avram
Avram

Reputation: 4259

use

  AppDomain.CurrentDomain.UnhandledException

before creating winform, you need to add this line

 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

Upvotes: 1

Marc Wittke
Marc Wittke

Reputation: 3155

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.

Upvotes: 0

Related Questions