开发者

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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜