ASP.NET Health Monitoring doesn't log inner exception stack trace

Security Briefs

Syndication

This can be a problem, especially when an ObjectDataSource starts throwing exceptions. The stack trace looks the same because of the way the methods are invoked (via reflection) - you end up with a stack trace for a TargetInvocationException, which basically says, "I used reflection to invoke some method, and it threw an exception. See the inner exception for details."

ASP.NET's health monitoring system does list the inner exceptions (apparently up to a maximum depth of two, from spelunking the code with reflector), but it does not emit the stack traces for these exceptions, which would be really helpful. I've spent some time this morning trying to figure out how I'd customize things to emit this, and it looks like what I'd have to do is catch the exception and generate a custom WebEvent that overrides ToString(bool, bool) and does everything that WebRequestErrorEvent does, but also generate the inner stack trace.

That seems a bit ugly. A search for "ASP.NET web event inner exception stack trace" yielded no interesting results, so if you've dealt with this and have a cleaner solution, let me know. I'll post my solution once I get it worked out.

UPDATE: I ended up writing a custom email provider.


Posted Aug 01 2008, 10:21 AM by keith-brown
Filed under: ,

Comments

Israel Aece wrote re: ASP.NET Health Monitoring doesn't log inner exception stack trace
on 08-01-2008 11:02 AM

Hello Keith,

I believe that the FormatToString method of the WebBaseErrorEvent class can help.

Inside of this method there is a code that extracts innerException but with only two loops.

Security Briefs wrote Better exception reporting in ASP.NET
on 08-01-2008 2:30 PM

In my last post , I commented on how ASP.NET health monitoring doesn't output stack traces for inner

Security Briefs wrote Better exception reporting in ASP.NET part 2
on 08-04-2008 8:11 AM

This is the third post in a series. The first post described the problem: ASP.NET wasn't reporting

Add a Comment

(required)  
(optional)
(required)  
Remember Me?