c# finalizer throwing exception?

Posted by sjhuk on Stack Overflow See other posts from Stack Overflow or by sjhuk
Published on 2010-04-22T15:09:12Z Indexed on 2010/04/22 15:13 UTC
Read the original article Hit count: 329

Filed under:
|
|

Quote from MSDN:

If Finalize or an override of Finalize throws an exception, the runtime ignores the exception, terminates that Finalize method, and continues the finalization process.

Yet if I have:

~Person()
{
throw new Exception("meh");
}

then it results in a runtime exception?

p.s. I know that this should never happen, however I'm just curious around this behaviour. One of our clients had an empty try catch around all of their finalizers.. it didn't even log when things went wrong or reserect the object :/

© Stack Overflow or respective owner

Related posts about c#

Related posts about garbage-collection