Enterprise Library Jan 2006 - custom exception formatter fails unless running debugger

Discussion in 'ASP .Net' started by David Herbst, Jan 23, 2006.

  1. David Herbst

    David Herbst Guest

    Enterprise Library Jan 2006 with Visual Studio 2005 on Windows 2000
    Server sp4.

    My custom exception formatter fails with a "Unable to handle exception:
    'LoggingExceptionHandler'." exception. When I attached the debugger to
    the process and stepped into the code it executed without error. In
    both cases I was running a Debug build, the only difference in the case
    that works is that I attached the debugger to the same exact binaries.
    Note: the error also occurs in a Release build.

    *** Start excerpt from web.config ***

    <exceptionHandling>
    <exceptionPolicies>
    <add name="General">
    <exceptionTypes>
    <add type="System.Exception, mscorlib, Version=2.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089"
    postHandlingAction="NotifyRethrow" name="Exception">
    <exceptionHandlers>
    <add logCategory="General" eventId="100" severity="Error"
    title="Enterprise Library Exception Handling"
    formatterType="Shared.WebTextExceptionFormatter,
    Shared, Version=1.0.2213.28731, Culture=neutral, PublicKeyToken=null"
    priority="0"
    type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler,
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
    name="Logging Handler" />
    </exceptionHandlers>
    </add>
    </exceptionTypes>
    </add>
    </exceptionPolicies>
    </exceptionHandling>

    *** End excerpt from web.config ***

    *** Start Event Log entry ***

    Event Type: Warning
    Event Source: ASP.NET 2.0.50727.0
    Event Category: Web Event
    Event ID: 1309
    Date: 1/22/2006
    Time: 5:33:36 PM
    User: N/A
    Computer: abc3
    Description:
    Event code: 3005
    Event message: An unhandled exception has occurred.
    Event time: 1/22/2006 5:33:36 PM
    Event time (UTC): 1/23/2006 1:33:36 AM
    Event ID: b42e0b6c76d64c2c8a3cd9acdeac7a93
    Event sequence: 30
    Event occurrence: 1
    Event detail code: 0

    Application information:
    Application domain: /LM/W3SVC/1/Root/Set-3-127824536009911250
    Trust level: Full
    Application Virtual Path: /Set
    Application Path: D:\00-data\Dev\Settlement\www-set-development\
    Machine name: abc3

    Process information:
    Process ID: 3432
    Process name: aspnet_wp.exe
    Account name: abc3\ASPNET

    Exception information:
    Exception type: ExceptionHandlingException
    Exception message: Unable to handle exception:
    'LoggingExceptionHandler'.

    Request information:
    Request URL: http://localhost/Set/Billing/ParticipantMessages.aspx
    Request path: /Set/Billing/ParticipantMessages.aspx
    User host address: 127.0.0.1
    User: corporate\abc
    Is authenticated: True
    Authentication Type: NTLM
    Thread account name: abc3\ASPNET

    Thread information:
    Thread ID: 7
    Thread account name: abc3\ASPNET
    Is impersonating: True
    Stack trace: at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry.ExecuteHandlerChain(Exception
    ex, Guid handlingInstanceID)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry.Handle(Exception
    exceptionToHandle)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl.HandleException(Exception
    exceptionToHandle)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception
    exceptionToHandle, String policyName)
    at Shared.BasePage.OnError(EventArgs e)
    at System.Web.UI.Page.HandleError(Exception e)
    at System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest()
    at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext
    context)
    at System.Web.UI.Page.ProcessRequest(HttpContext context)
    at ASP.billing_participantmessages_aspx.ProcessRequest(HttpContext
    context)
    at
    System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
    Boolean& completedSynchronously)


    Custom event details:

    *** End Event Log entry ***
     
    David Herbst, Jan 23, 2006
    #1
    1. Advertising

  2. David Herbst

    David Herbst Guest

    It turns out that it also fails in the debugger, although only
    intermittently.

    I finally discovered that the problem was that the ServerVariables
    collection was being changed while my custom formatter was doing a "for
    each" loop to dump these variables into the exception message. I have
    no idea what would cause the ServerVariables to change while the page
    is being processed but I did the exact same "for each" loop on this
    collection in .NET 1.1 for a year or more without encountering this
    problem.

    Anyway, the solution I implemented to solve this problem was to first
    create a copy of the ServerVariables by instantiating a new
    NameObjectKeysEnumerator object and passing in the ServerVariables
    collection to the constructor. I can then iterate the copy of this
    collection without it changing on me.

    BTW a "Collection was modified after the enumerator was instantiated."
    exception gets thrown by NameObjectKeysEnumerator.MoveNext() when this
    happens but Enterprise Library catches the exception and throws a new
    generic "Unable to handle exception: 'LoggingExceptionHandler'."
    exception without assigning the lower level exception to the inner
    exception property of the new exception. It would have saved me a lot
    of time if Enterprise Library wrapped the old exception instead of just
    creating a new meaningless generic one. Since this problem was
    intermittent it wasn't easy to track this down even using a debugger.
     
    David Herbst, Jan 29, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Z2FsaWNv?=
    Replies:
    8
    Views:
    3,223
    aashishgandhi
    Nov 13, 2007
  2. Wade
    Replies:
    3
    Views:
    583
    =?Utf-8?B?TXVydGF6YQ==?=
    Jul 25, 2006
  3. sathyashrayan

    clc selected threads (30-jan-2005 to 31-jan-2005) #1

    sathyashrayan, Feb 6, 2005, in forum: C Programming
    Replies:
    3
    Views:
    382
    Mark McIntyre
    Feb 7, 2005
  4. A.M-SG

    Switching from XML formatter to Binary Formatter

    A.M-SG, Nov 21, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    345
    Steven Cheng[MSFT]
    Nov 22, 2005
  5. Gábor SEBESTYÉN

    Unless unless

    Gábor SEBESTYÉN, Jun 17, 2005, in forum: Ruby
    Replies:
    3
    Views:
    169
    Gábor SEBESTYÉN
    Jun 17, 2005
Loading...

Share This Page