简体   繁体   English

在asp.net WebService中未调用Application_End时

[英]When Application_End isn't called in asp.net WebService

I know that in the following cases Apllication_end will be called: 我知道在以下情况下会调用Apllication_end:

  1. edit the config file for an application that's running. 编辑正在运行的应用程序的配置文件。
  2. change a dll in the bin directory. 更改bin目录中的dll。
  3. stop (or restart) IIS. 停止(或重新启动)IIS。
  4. Process Recycling turned on either in IIS6 App Pools, or using the aspnet worker process. 在IIS6应用程序池中或使用aspnet工作进程打开了进程回收。

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: 这种情况发生的唯一时间是:

  1. an action caused IIS to restart the service process (changing a file would force this) 一个动作导致IIS重新启动服务进程(更改文件会强制执行此操作)
  2. the IIS service is shut down IIS服务已关闭
  3. process recycling. 工艺回收。

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.

相关问题 我的ASP.NET MVC网站中的Application_end方法几乎同时被多次奇怪地调用 - The Application_end method in my ASP.NET MVC website is called many times weirdly almost at the same time 在asp.net中托管套接字服务 - 与application_start和application_end有关 - Hosting a socket service in asp.net - issues with application_start & application_end Application_End和后台进程,正常退出ASP.Net应用程序 - Application_End and background processes, exiting ASP.Net application gracefully 在IIS中回收应用程序池时,是否调用Application_End? - When an application pool is recycled in IIS, is the Application_End called? Application_End未运行 - Application_End Not Running 当我关闭 Visual Studio 时,Application_end 事件不会更新数据库 - Application_end event doesn't update the database when I close visual studio 调试 IIS 网站时,ASP.NET Core 2 Web 应用程序未加载用户机密 - ASP.NET Core 2 web application isn't loading user secrets when debugging IIS website ASP.NET 内核 - 注册应用程序关闭不起作用 - ASP.NET Core - Registering for Application Shutdown isn't working 当应用程序强制结束时,ASP.Net应用程序数据未更新 - ASP.Net Application Data not updating when application forcibly end 从另一个应用程序调用的webservice传递值到asp.net网站 - Passing values from webservice called by another application to asp.net website
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM