title: How do I programmatically find why Application_End() is invoked?
body: <p><code>Application_End()</code> is invoked when my application pool is stopped which can happen for a number of reasons, including automatic pool recycle or changes in the folder from which the application is served.</p>
  
  <p>The call stack will typically looks like this:</p>
  
  <pre><code>my Application_End(Object sender, EventArgs e)
  at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
  at System.Web.HttpApplication.InvokeMethodWithAssert(MethodInfo method, Int32 paramCount, Object eventSource, EventArgs eventArgs)
  at System.Web.HttpApplication.ProcessSpecialRequest(HttpContext context, MethodInfo method, Int32 paramCount, Object eventSource, EventArgs eventArgs, HttpSessionState session)
  at System.Web.HttpApplicationFactory.Dispose()
  at System.Web.HttpRuntime.Dispose()
  at System.Web.HttpRuntime.ReleaseResourcesAndUnloadAppDomain(Object state)
  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
  at System.Threading.ThreadPoolWorkQueue.Dispatch()
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
  </code></pre>
  
  <p>which is completely useless.</p>
  
  <p>How do I programatically find why it was called?</p>