簡體   English   中英

使用企業庫時,WCF服務中的“無法識別的配置節異常處理”

[英]“Unrecognized configuration section exceptionHandling” in WCF service when using Enterprise Library

我正在使用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>

我想到了。 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>

您是否有<exceptionHandling>的結束標記?還是只是忘記將其復制/粘貼到示例中?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM