我在我的应用程序服务器端使用Enterprise应用程序块来处理异常。关于捕捉FaultException <T> ex
我能够成功地处理异常。我创建了一个自定义服务错误类来处理异常。
这里是我的web配置enteries ...
<exceptionPolicies>
<add name="WCF Exception Shielding">
<exceptionTypes>
<add type="TEST.Infrastructure.ExceptionHandling.Exceptions.TESTBusinessException, Pluto.Infrastructure.ExceptionHandling, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
postHandlingAction="ThrowNewException" name="TESTBusinessException">
<exceptionHandlers>
<add logCategory="BusinessLoggingCategory" eventId="501" severity="Error"
title="Pluto Service Exception" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
priority="0" useDefaultLogger="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Logging Handler" />
<add
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="DefaultFaultContract Handler"
faultContractType="TEST.Infrastructure.ExceptionHandling.Exceptions.TESTServiceException, Pluto.Infrastructure.ExceptionHandling"
exceptionMessage="Pluto.Infrastructure.ExceptionHandling.Exceptions.TESTBusinessException {handlingInstanceID}">
<mappings>
<add name="Id" source="{Guid}"/>
<add name="MessageText" source="{Message}"/>
</mappings>
</add>
</exceptionHandlers>
</add>
但在客户端上时,我试图抓住这个异常的
catch (FaultException<TESTServiceException> fex)
{
}
这个异常没有被捕获。 我能够在客户端获取我在服务器端的app.config中写入的异常消息。
任何人都可以帮我找出问题。
在此先感谢
维克拉姆
什么异常(包括'InnerException')**是你得到客户端? – 2009-12-09 10:14:09
我正在异常类型 System.ServiceModel.FaultException的,而不是类型的 System.ServiceModel.FaultException –
2009-12-09 10:29:52
和内部异常为NULL。 – 2009-12-09 10:36:09