为什么我们使用Fault契约而不是Try-catch块? [英] Why we use Fault contract instead of Try-catch block?

查看:142
本文介绍了为什么我们使用Fault契约而不是Try-catch块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们使用Fault契约而不是Try-catch块?

Why we use Fault contract instead of Try-catch block?

推荐答案

阅读以下文章



故障合同 - 处理WCF和A中的错误非常简单的WCF服务实现 [ ^ ]


用最简单的术语来说,Try / Catch块是处理异常的本地方式 - 如果可以的话立即与您的用户进行交互,然后您只需使用它并可能显示错误消息。



故障合同可用于程序与服务交互的地方,并允许服务将异常的详细信息发送回客户端进程(以受控方式) )
In its simplest terms a Try/Catch block is a "local" way of handling exceptions - if you can immediately interact with your user then you would just use this and perhaps display an error message.

A Fault Contract can be used where a program is interacting with a service and allows the service to send details of an exception back to the client process (in a controlled manner)


由于异常屏蔽,您应该使用故障合同。



在Windows Communication Foundation(WCF)中,未向客户端应用程序发送未知异常,以防止服务实现的详细信息逃避服务的安全边界。 br $>


JAFC
You should use a fault contract because of exception shielding.

In Windows Communication Foundation (WCF), unknown exceptions are not sent to the client application to prevent details of the service implementation from escaping the secure boundary of the service.

JAFC


这篇关于为什么我们使用Fault契约而不是Try-catch块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆