AppDomain.FirstChanceException and stack overflow exception

前端 未结 7 1692

I\'m using the FirstChanceException event to log details about any thrown exceptions.

static void Main(string[] args)
{
    AppDomain.CurrentDomain.FirstChanceEx         


        
7条回答
  •  逝去的感伤
    2021-02-05 11:20

    I think adding another try {} catch (){} block in the exception handler would help

    static void Main(string[] args) 
    { 
        AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) => 
        { 
            try {
                throw new Exception("Stackoverflow"); 
            } catch (Exception e)
            {
               // Do something very simple not throwing an exception...
            }
        }; 
    
        throw new Exception("Exception thrown in main."); 
    } 
    

提交回复
热议问题