Policy name 'Global Policy' could not be found.

Topics: Exception Handling Application Block
Aug 20, 2009 at 5:50 PM

Really I am very fed up  with this error type.I can't find anything reasonable solution.

I would be thankful if anyone help me on this.

 

I placed this line between<configSection>

<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" />

and my below tags were between configuration tag.

<exceptionHandling>
    <exceptionPolicies>
      <add name="Global Policy">
        <exceptionTypes>
          <add name="Exception"
          type="System.Exception,
            mscorlib, Version=2.0.0.0,
            Culture=neutral,
            PublicKeyToken=b77a5c561934e089"
          postHandlingAction="None">
            <exceptionHandlers>
              <add name="Application
               Message Handler"
                 type="ExceptionMgmtBlockExample.
                   AppMessageExceptionHandler,             
                   ExceptionMgmtBlockExample"/>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>

 

My code doesn't catch the exception so for.

try
        {
            int a = 0;
            int b = 1;
            int result = b / a;
        }
        catch (System.Exception ex)
        {
            bool rethrow = ExceptionPolicy.HandleException(ex, "Global Policy");
            if (rethrow)
            {
                throw;
               
            }
        }

Aug 24, 2009 at 7:17 AM

Hi,

The config you've posted seems to be fine. Do you get any exception while running the code? What is the expected output when using your custom handler? Is this in the context of Winforms or Web?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Aug 25, 2009 at 12:27 AM

Your configuration file might be in a class library.  Config files should be in an executable project even if the exceptionhandling codes are in a class library.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com