为什么企业库不在WCF中抛出FaultException

为什么企业库不在WCF中抛出FaultException,wcf,exception-handling,enterprise-library,enterprise-library-5,wcf-faults,Wcf,Exception Handling,Enterprise Library,Enterprise Library 5,Wcf Faults,我使用托管在IIS上的WCF服务。 此外,我还使用故障契约将错误发送到客户端FaultException,以向用户显示一些错误。 如果在服务器上引发未处理的异常,WCF将生成纯FaultException, 所以客户端捕捉到它并显示用户内部服务器错误消息 然后我开始使用EnterpriseLibrary5.0进行WCF异常屏蔽,并遇到了以下问题。使用FaultContractExceptionHandler可以将所有错误传递给客户端,但在未处理异常的情况下,客户端将接收Communication

我使用托管在IIS上的WCF服务。 此外,我还使用故障契约将错误发送到客户端FaultException,以向用户显示一些错误。 如果在服务器上引发未处理的异常,WCF将生成纯FaultException, 所以客户端捕捉到它并显示用户内部服务器错误消息

然后我开始使用EnterpriseLibrary5.0进行WCF异常屏蔽,并遇到了以下问题。使用FaultContractExceptionHandler可以将所有错误传递给客户端,但在未处理异常的情况下,客户端将接收CommunicationException而不是FaultException。其他一切都正常

若我关闭了异常处理策略remove ExceptionShielding attibute,客户机将按预期捕获FaultExceptions。 你知道原因是什么吗? 谢谢

PS:下面是一系列内部异常: CommunicationException->WebException->IOException->SocketException 消息是基础连接已关闭:服务器已关闭了预期保持活动状态的连接

Web.config

经营合同


这似乎是企业库的一个问题。看这个

<add name="ServiceException Policy">
    <exceptionTypes>
      <add name="ServiceLogicException" type="LopService.Contracts.ServiceLogicException, LopService.Contracts, Version=1.0.0.1725, Culture=neutral, PublicKeyToken=null"
        postHandlingAction="ThrowNewException">
        <exceptionHandlers>
          <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            faultContractType="LopService.Contracts.ServiceLogicFaultContract, LopService.Contracts, Version=1.0.0.1725, Culture=neutral, PublicKeyToken=null"
            name="Fault Contract Exception Handler" />
        </exceptionHandlers>
      </add>
    </exceptionTypes>
  </add>
[ExceptionShielding("ServiceException Policy")]
public partial class LopSoapService
{...
    [OperationContract]
    [FaultContract(typeof(DataValidationFaultContract))]
    [FaultContract(typeof(ServiceLogicFaultContract))]
    int CreateUser(UserDto userDto, IEnumerable<ClaimRecordDto> claimRecords);