2010-05-03 130 views
0

我正在使用WCF服務,並希望使用企業庫ExceptionHandling塊將錯誤消息發送回客戶端,但我遇到了問題。我在網上發現了很少這個錯誤。使用企業庫時WCF服務中的「無法識別的配置節exceptionHandling」

我在web.config中添加了exceptionHandling塊,並且還引用了configSections中的exceptionHandling,但仍然出現錯誤。

我也在我的項目中引用了ExceptionHandling.WCF dll。

我不應該做任何事情,但是當我發佈並在瀏覽器中啓動服務時,它仍會引發錯誤。

任何想法?這可能很簡單,但我找不到問題。下面是我在web.config中的相關章節:

 <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 

    <exceptionHandling> 
<exceptionPolicies> 
    <add name="WCF Exception Shielding"> 
    <exceptionTypes> 
     <add type="System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="ThrowNewException" name="ArgumentNullException"> 
     <exceptionHandlers> 
      <add 
      type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF" 
      name="DefaultFaultContract Handler" 
      faultContractType="Bursteg.Samples.WCFIntegration.ServiceContracts.ServiceFault, Bursteg.Samples.WCFIntegration.ServiceContracts"> 
      <mappings> 
       <add name="Id" source="{Guid}"/> 
       <add name="MessageText" source="{Message}"/> 
      </mappings> 
      </add> 
     </exceptionHandlers> 
     </add> 
    </exceptionTypes> 
    </add> 
</exceptionPolicies> 

回答

0

你有沒有<exceptionHandling>結束標籤還是你只是忘記你的樣品中複製/粘貼嗎?

+0

我有一個結束標記爲。只是沒有把它放進去。對不起。 – 2010-05-03 15:58:54

4

我想通了。 exceptionHandling引用需要是configSections的直接子節點。我有它的幾個節點,所以它沒有被引用。只是想我會傳遞我的解決方案。

另外,作爲側不,我提出的唯一引用是Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF

<configSections> 
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
</configSections> 
+1

您應該將您的答案標記爲已接受的答案。 – 2010-05-03 18:44:47