c# - Are there any circumstances under which the finally block does not get executed? -


please note code:

 class ctestfinally   {       public static void run()       {           try           {               tryandtry();           }           catch (exception exerror)           {               console.writeline(exerror.message);           }                     {               console.writeline("finally...!");           }           console.readkey();       }        static void tryandtry()       {           try           {               tryandtry();           }           catch (exception exerror)           {               console.writeline(exerror.message);           }                     {               console.writeline("try: finally...!");           }           } }       } 

finally never executed because stack overflow error.

are there circumstances under block not executed other above problem?

stackoverflowexception 1 of few kinds of exception clr host typically treats specially. asp.net kill worker process example. very hard debug because app goes away. sql server has similar policies i'm sure (like unloading appdomain).

the reason destabilizing condition not allow reliable error recovery (after stack unusable! can example not call logger or send email. there no room on stack.).

another of kind outofmemoryexception (you can't allocate exception - that's why clr pre-allocates 1 oom instance...). think asp.net tolerates while sql server kills appdomain.

for normal exceptions works fine.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -