AppDomain.OnUnhandledException : AppDomain « System « C# / C Sharp by API






AppDomain.OnUnhandledException

 

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.AppDomain.CreateInstance
3.AppDomain.CreateInstanceAndUnwrap
4.AppDomain.CreateInstanceFromAndUnwrap
5.AppDomain.CurrentDomain.FriendlyName
6.AppDomain.CurrentDomain
7.AppDomain.DefineDynamicAssembly
8.AppDomain.DoCallBack
9.AppDomain.DomainUnload
10.AppDomain.FriendlyName
11.AppDomain.GetAssemblies
12.AppDomain.GetData
13.AppDomain.ProcessExit
14.AppDomain.SetData
15.AppDomain.SetPrincipalPolicy
16.AppDomain.Unload