Just saw this post from Tess about unhandled exceptions in ASP.NET 2.0. Great post by the way, with lot of useful information (as always) about using windbg and logging unhandled exceptions.
I really needed that information a month ago when I encountered the exact same problem (exception in a finalizer) with an ASP.NET web service that crashed after being idle for a while.
Fortunately for me, since the error occurred after the web application has been idle I realized it happens when the application is shut down so I attached Visual Studio to the w3wp process and did an iisreset. The debugger then stopped at the offending line.
In case you’re curios why Lucene.net was mentioned in the subject, well, it’s because the bug was in Lucene. How do you fix this error? simple:
Open the SegmentReader.cs and TermInfosReader.cs files and search for the finalizer of the classes declared there (simply search for ~), both those classes contains calls to
comment the above line (actually you can remove the finalizer all together as that’s the only thing it does) and that’s it. This line was ported from the Java version of Lucene.net where this line was added to work around a bug in pre-1.4.2 JVMs. This patch is not needed in .net.
If you’re using ASP.NET 1.1/1.0 then you didn’t encounter this bug since the framework swallows these exception (see Tess’s post for more info).