Reputation: 67233
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
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
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