【问题标题】:How do I programmatically find why Application_End() is invoked?如何以编程方式找到调用 Application_End() 的原因?
【发布时间】:2013-01-29 03:21:32
【问题描述】:

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()

这完全没用。

如何以编程方式找到调用它的原因?

【问题讨论】:

    标签: asp.net .net iis application-pool


    【解决方案1】:

    System.Web.Hosting.HostingEnvironment.ShutdownReason 属性指示应用程序被终止的原因。它的值可以从Application_End()内部获取。

    【讨论】:

    • 感谢您的回答,这对我很有帮助!似乎我在启动时修改了应用程序的 /bin 目录中的一个文件,触发了 Application_End()。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-09
    • 2020-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多