GurdeepS
GurdeepS

Reputation: 67233

Managing exceptions in WCF - should they travel over the boundary to the calling application, and if so how?

I have a WCF service hosted in a windows service. This is called by a winforms app. The windows service may raise an exception its in execution, but if it does, is there a way to get this to travel into the winforms app?

Or would it be best to have the exception not to travel across boundaries?

Thanks

Upvotes: 2

Views: 303

Answers (2)

Andrew Shepherd
Andrew Shepherd

Reputation: 45262

Yes, it is possible to transfer exceptions across the WCF boundaries.

See FaultContract for how you can specify exceptions in the service contract.

In my experience, it is quite beneficial to throw exceptions across the WCF boundaries. This allows the client code to handle remote WCF errors just like any other .NET errors. You're working at a higher level of abstraction.

Upvotes: 3

razlebe
razlebe

Reputation: 7144

Yes: you can throw exceptions across service boundries by specifying faults in your service contracts. The WCF terminology you want is "Fault Contract" - see this documentation.

Upvotes: 2

Related Questions