I have a WCF service hosted in a w开发者_运维问答indows 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
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.
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.
精彩评论