[英]When Application_End isn't called in asp.net WebService
I know that in the following cases Apllication_end will be called: 我知道在以下情况下会调用Apllication_end:
but my question is what are the cases when it's won't be called? 但我的问题是什么时候它不会被调用?
I know it won't be called if you manually End w3wp process or if the server will brutally shut down. 我知道如果你手动结束w3wp进程或服务器将被严重关闭,它将不会被调用。
Is there any other scenarios? 还有其他场景吗?
Thanks! 谢谢!
The answer to your question is basically in your question already. 您的问题的答案基本上已经在您的问题中。 Application_End is called anytime the process hosting your web service shuts down gracefully.
每当托管您的Web服务的进程正常关闭时,都会调用Application_End。
The only time this would happen is: 这种情况发生的唯一时间是:
If the process is terminated abruptly (ie killing the w3wp process), it won't get a chance to run. 如果进程突然终止(即杀死w3wp进程),它将无法运行。
It seems that the brutal shut down can be caused by OutOfMemoryException that caused failure in creating AppDomain that are needed for executing requests. 似乎残酷的关闭可能是由OutOfMemoryException导致的,这导致创建执行请求所需的AppDomain失败。 In this scenario Application_end won't be called.
在这种情况下,不会调用Application_end。
Event Type: Error
事件类型:错误
Event Source: ASP.NET 2.0.50727.0事件来源:ASP.NET 2.0.50727.0
Event Category: None活动类别:无
Event ID: 1334事件ID:1334
Date: 4/22/2012日期:2012年4月22日
Time: 11:23:13 AM时间:上午11:23:13
User: N/A用户:N / A.
Computer: CCBSHAIS02计算机:CCBSHAIS02
Description:描述:
Failed to initialize the AppDomain:/LM/W3SVC/1/Root/AgentWS无法初始化AppDomain:/ LM / W3SVC / 1 / Root / AgentWS
Exception: System.SystemException
例外:System.SystemException
Message: Failed to create AppDomain.
消息:无法创建AppDomain。
StackTrace: at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters) at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
StackTrace:位于System.Web.HostingEnvironment(String appId,IApplicationHost appHost,HostingEnvironmentParameters hostingParameters)的System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId,IApplicationHost appHost,HostingEnvironmentParameters hostingParameters)
InnerException: System.OutOfMemoryException
InnerException:System.OutOfMemoryException
Message: Exception of type 'System.OutOfMemoryException' was thrown.
消息:抛出了类型'System.OutOfMemoryException'的异常。
StackTrace: at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor) at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info) at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
StackTrace:位于System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment的System.AppDomain.CreateDomain(String friendlyName,Evidence securityInfo,AppDomainSetup info)的System.AppDomain.nCreateDomain(String friendlyName,AppDomainSetup setup,Evidence providedSecurityInfo,Evidence creatorsSecurityInfo,IntPtr parentSecurityDescriptor)。 (String appId,IApplicationHost appHost,HostingEnvironmentParameters hostingParameters)
for further reading on IIS and AppDomains look at: http://weblogs.asp.net/owscott/archive/2007/09/02/application-vs-appdomain.aspx 有关IIS和AppDomains的进一步阅读,请访问: http : //weblogs.asp.net/owscott/archive/2007/09/02/application-vs-appdomain.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.