Visual Studio 2012, C#, .NET 4.5를 사용하여 Windows Forms
응용 프로그램을 만듭니다. Windows 7예외 처리기는 Visual Studio 내에서 실행될 때만 작동합니다.
나는 자체 오류 처리기로 처리되지 않은 예외를 처리하고 싶습니다. 나는 아래와 같은 코드를 작성했다. 심지어 두 가지 오류 처리 방법을 시도했습니다.
이제 Visual Studio (2012)에서이 프로그램을 실행하면 매우 잘 작동합니다!
그러나 탐색기에서 프로그램을 시작할 때 오류 처리기가 호출되지 않습니다. 대신 .NET Framework에서 항상 표준 오류 처리기가 나타납니다.
그래서 내가 뭘 잘못하고 있니?
static void Main()
{
try
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(HandleUnhandledException);
Application.Run(new frmMainFrame());
}
catch (Exception ex)
{
// Here is my error handler ....
}
}
static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs args)
{
Exception ex = (Exception) args.ExceptionObject;
// Here is my error handler ....
}
예, 작동했습니다! Application.SetUnhandledExceptionMode (UnhandledExceptionMode.ThrowException); Visual Studio에서는 기본적으로이 모드를 설정하고 탐색기는 설정하지 않는 것으로 보입니다. 감사 !! –
@Giosco : Explorer는 아무 관련이 없습니다. – siride
@ silid - 이것을 더 자세히 설명 할 수 있습니까? 지금까지 이해했듯이, 시작 환경은 UnhandledExceptionMode를 설정하고 Visual Studio와 Explorer는이를 다르게 처리합니다. –