Sage.Project.Application_End C# (CSharp) Method

Application_End() protected method

Handles the End event of the Application control.
Logs the application shutdown event, together with the reason and detail of the shutdown.
protected Application_End ( object sender, EventArgs e ) : void
sender object The source of the event.
e System.EventArgs The instance containing the event data.
return void
        protected virtual void Application_End(object sender, EventArgs e)
        {
            HttpRuntime runtime = (HttpRuntime) typeof(HttpRuntime).InvokeMember(
                "_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);

            if (runtime == null)
                return;

            string shutDownMessage = (string) runtime.GetType().InvokeMember(
                "_shutDownMessage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);

            string shutDownStack = (string) runtime.GetType().InvokeMember(
                "_shutDownStack", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);

            log.InfoFormat("Application has shut down.");
            log.DebugFormat("	Shutdown message:{0}", shutDownMessage);
            log.DebugFormat("	Shutdown stack:\n{0}", shutDownStack);

            initializationError = null;
        }