OnUnhandledException method is added to the AppDomain.UnhandledException event : AppDomain « Development Class « C# / C Sharp






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);
    }
}

 








Related examples in the same category

1.AppDomain.CreateDomain
2.SetData, GetData
3.Configure the AppDomainSetup
4.SetPrincipalPolicy
5.FriendlyName
6.creates three instances of the same type. A local and two remote proxies to object instances are constructed: