C# catch a stack overflow exception

前端 未结 9 1079
生来不讨喜
生来不讨喜 2020-11-22 09:12

I have a recursive call to a method that throws a stack overflow exception. The first call is surrounded by a try catch block but the exception is not caught.

Does

9条回答
  •  甜味超标
    2020-11-22 09:59

    It's impossible, and for a good reason (for one, think about all those catch(Exception){} around).

    If you want to continue execution after stack overflow, run dangerous code in a different AppDomain. CLR policies can be set to terminate current AppDomain on overflow without affecting original domain.

提交回复
热议问题