Posted
Filed under C#

using System;

class Program {
    static void Main(string[] args) {
        System.AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;
        throw new Exception("Kaboom");
    }

    static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e) {
        Console.WriteLine(e.ExceptionObject.ToString());
        Console.WriteLine("Press Enter to continue");
        Console.ReadLine();
        Environment.Exit(1);
    }
}

// c#에서 Console(콘솔) 어플리케이션에서 글로벌 에러 처리
   반복 작업시 유용하게 이용

 

 

2016/10/13 09:14 2016/10/13 09:14