I use WCF service hosted on IIS.
Also, I use fault contracts to send errors to the client (FaultException<'T>)
On the client side I catch FaultException<'T> to show some error to user.
If some unhandled exception being thrown on a server, WCF generates plain FaultException,
so client catches it and shows user "Internal Server Error" message.
Then I began to use Enterprise Library 5.0 for WCF Exception Shielding, and met following issue. Using FaultContractExceptionHandler it is possible to carry all errors to the client, but in case of unhandled exception client receives CommunicationException instead of FaultException. Everything other works ok.
If I turned off exception handling policy (remove ExceptionShielding attibute), client catches FaultExceptions as expected.
Do you know what may be the reason?
Thanks.
PS: Here is a chain of inner exceptions:
CommunicationException -> WebException -> IOException -> SocketException
Message is "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server."
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>
Service Class
[ExceptionShielding("ServiceException Policy")]
public partial class LopSoapService
{...
Operation Contract
[OperationContract]
[FaultContract(typeof(DataValidationFaultContract))]
[FaultContract(typeof(ServiceLogicFaultContract))]
int CreateUser(UserDto userDto, IEnumerable<ClaimRecordDto> claimRecords);
This appears to be an issue with Enterprise Library. See this workitem.