【发布时间】: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