By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 ***

<add name="General">
<add type="System.Exception, mscorlib, Version=,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="NotifyRethrow" name="Exception">
<add logCategory="General" eventId="100" severity="Error"
title="Enterprise Library Exception Handling"
Shared, Version=1.0.2213.28731, Culture=neutral, PublicKeyToken=null"
type="Microsoft.Practices.EnterpriseLibrary.Except ionHandling.Logging.LoggingExceptionHandler,
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.Logging,
Version=, Culture=neutral, PublicKeyToken=null"
name="Logging Handler" />

*** 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
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:

Request information:
Request URL: http://localhost/Set/Billing/ParticipantMessages.aspx
Request path: /Set/Billing/ParticipantMessages.aspx
User host address:
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.ExceptionHan dling.ExceptionPolicyEntry.ExecuteHandlerChain(Exc eption
ex, Guid handlingInstanceID)
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicyEntry.Handle(Exception
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicyImpl.HandleException(Exceptio n
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.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(Http Context
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.billing_participantmessages_aspx.ProcessReques t(HttpContext
System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApplication.IExecutionStep.Execut e()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)
Custom event details:

*** End Event Log entry ***

Jan 23 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
It turns out that it also fails in the debugger, although only

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

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.

Jan 29 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.