Enterprise Library 6.0 - 异常处理块 - 在配置源中找不到异常处理的配置部分

时间:2013-12-03 04:33:38

标签: exception-handling enterprise-library-5

我们使用企业库6.0-特殊处理块和配置控制台来定义策略。

The following code has been generated in app.config file for the defined policy



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    </configSections>
    <exceptionHandling>
        <exceptionPolicies>
            <add name="DataAccessPolicy">
                <exceptionTypes>
                    <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                        postHandlingAction="ThrowNewException">
                        <exceptionHandlers>
                            <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                                exceptionMessage="An occured in the data &#xD;&#xA;access layer.&#xD;&#xA;Please Contact the &#xD;&#xA;Admin with Error Id { }."
                                replaceExceptionType="Mindtree.Azure.PaymentGatewayExceptionHandler.DataAccessException, Mindtree.Azure.PaymentGatewayExceptionHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
                        </exceptionHandlers>
                    </add>
                </exceptionTypes>
            </add>
        </exceptionPolicies>
    </exceptionHandling>
</configuration>


I have the following code in my catch block, i am defining manager using configuration source factory and setting the exception manager

            IConfigurationSource config = ConfigurationSourceFactory.Create();
            ExceptionPolicyFactory factory = new ExceptionPolicyFactory(config);
            ExceptionPolicy.SetExceptionManager(factory.CreateManager())
            bool rethrow = ExceptionPolicy.HandleException(ex,"DataAccessPolicy");
            if(rethrow)
            throw;
DataAccessPolicy is defined in the app.config file which uses the repalce handler

but the following error is thrown when debugging 

在配置源中找不到异常处理的配置部分。

Any Help would be appereciated. Thanks in advance

0 个答案:

没有答案