1

we are using enterprise library 6.0- exceptional handling block and configuration console for defining policy.

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 

The configuration section for Exception Handling cannot be found in the configuration source.

Any Help would be appereciated. Thanks in advance
madhu
  • 71
  • 1
  • 11
  • Is your .config in the output folder? – Aaron Palmer Dec 03 '13 at 18:00
  • @AaronPalmer : hi, I'm also facing the same problem as this.. can you please explain what you mean by `output folder`? I'm trying to use this in class library in data layer. – Sid M Aug 13 '14 at 12:36
  • 1
    My suggestion was basically a sanity check. Make sure that wherever your output is placed when you are running (ie: `\Bin\Debug`) actually contains the .config file and has the expected configSection defined. Another thing to check is that the version information in the configSection is indeed the version that is available at runtime (whether it is GAC'd or copied locally). – Aaron Palmer Aug 13 '14 at 14:23
  • @AaronPalmer : Thanks alot it worked... returning your favour in some upvotes :) – Sid M Aug 14 '14 at 06:48

0 Answers0