Asp.net
如何以程式方式找到呼叫 Application_End() 的原因?
Application_End()當我的應用程序池停止時呼叫,這可能由於多種原因而發生,包括自動池回收或提供應用程序的文件夾中的更改。呼叫堆棧通常如下所示:
my Application_End(Object sender, EventArgs e) at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& 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()這是完全沒用的。
我如何以程式方式找到它被呼叫的原因?
有一個
System.Web.Hosting.HostingEnvironment.ShutdownReason屬性表明應用程序被終止的原因。可以從內部檢索其值Application_End()。