OnUnhandledException method is added to the AppDomain.UnhandledException event : AppDomain : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » AppDomain »

 

OnUnhandledException method is added to the AppDomain.UnhandledException event








    
 

using System;

public class Starter {
    public static void Main() {
        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
        int vara = 5, varb = 0;
        vara /= varb;
    }

    public static void OnUnhandledException(
            object sender, UnhandledExceptionEventArgs e) {
        string application_name = sender.ToString();
        Exception except = (Exception)e.ExceptionObject;
        string errormessage = "Application " + application_name +
            " [ Exception " + except.Message + " ]";
        Console.WriteLine(errormessage);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» AppDomain