'c# 전역 Exception 처리'에 해당되는 글 1건

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(콘솔) 어플리케이션에서 글로벌 에러 처리
   반복 작업시 유용하게 이용

반응형
블로그 이미지

visualp

c#, java

,