我在我的應用程序服務器端使用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