locked
Error while using exception handling block el 4.1 RRS feed

  • Question

  • User156383950 posted

    Hi Folks,

     

    i am trying to use tyhe exception handling block of Enterprise library 4.1.

     

    I just createda polisy and used IndexOutOfRangeException and added a replace handler and a logging handler to it.

    I am using the NotifyRethrow PostHandlingAction to the exception.

     

    During runtime I am getting an exception on the HandleException event, The exception is added below:

     

     

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 42:             catch (Exception ex)
    Line 43:             {
    Line 44:                 bool reThrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy");
    Line 45:                 if (reThrow)
    Line 46:                 {

     
    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingConfigurationView.GetExceptionPolicyData(String policyName) +115
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.GetConfiguration(String id, IConfigurationSource configurationSource) +62
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) +94
       Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context) +248
       Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +119
    
    [BuildFailedException: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, ReplacePolicy]) failed: Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)]
       Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +349
       Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing) +102
       Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing) +52
       Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, String id, IConfigurationSource configurationSource) +519
       Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase`1.Create(String name) +131
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ExceptionPolicyFactory factory) +93
    
    [ExceptionHandlingException: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, ReplacePolicy]) failed: Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)]
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ExceptionPolicyFactory factory) +300
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName, ExceptionPolicyFactory policyFactory) +45
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName) +153
       SunTrust.KMS.Repository.DBAccessmethods.GetAlertsMetaData(String userGroup, Int32 startRecord, Int32 recordsPerPage, Int32& totalRecords) in C:\Projects\KMS Presentation\Source\Repository\DBAccessmethods.cs:44
       SunTrust.KMS.Repository.KMSFacade.GetAlertsMetaData(String userGroup, Int32 startRecord, Int32 recordsPerPage, Int32& totalRecords) in C:\Projects\KMS Presentation\Source\Repository\KMSFacade.cs:24
       SunTrust.KMS.UserControls.ucxHomeAnnouncements.Page_Load(Object sender, EventArgs e) in C:\Projects\KMS Presentation\Source\KMS\Categories\UserControls\ucxHomeAnnouncements.ascx.cs:60
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
    

     

    Guys,

     

    Please tell me where i am going wrong.

     

    Thanks,

    Srikant

    Friday, March 19, 2010 1:10 AM

All replies