【问题标题】:"Unrecognized configuration section exceptionHandling" in WCF service when using Enterprise Library使用企业库时 WCF 服务中的“无法识别的配置节异常处理”
【发布时间】:2010-05-03 14:21:19
【问题描述】:

我正在开发 WCF 服务并希望使用 Enterprise Library 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>

【问题讨论】:

    标签: c# .net asp.net enterprise-library web-config


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      您是否有 &lt;exceptionHandling&gt; 的结束标签,或者您只是忘记将其复制/粘贴到您的示例中?

      【讨论】:

      • 我有一个 的结束标签。刚刚错过了。抱歉。
      猜你喜欢
      • 1970-01-01
      • 2011-02-27
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-30
      • 1970-01-01
      • 2011-02-19
      相关资源
      最近更新 更多