HostingEnvironment initiated shutdown exception logged in Event log
In the last couple of days we received several tickets where you asked us what does it mean and why this exception is being logged in the Event log. You can find more information about it in this blog post.
There are several possible causes of this issue, mostly caused by .Net framework or settings of IIS application pool:
- The application pool in IIS can be set to recycle the application if some limits are exceeded - CPU usage, Memory, idle time
- .Net is restarting application automatically when there is a change in web.config file, BIN, App_Code directory and other directories. It is the standard .Net behavior (Why might a .NET web application (app domain) restart? The reasons may surprise you
- Another possible option is that the number of recompilation was reached. .Net framework is restarting automatically the application after a specified number of compilations - e.g. you have edited some code files, etc. This can be set in web.config file, default value is 100:
<compilation debug="false" numRecompilesBeforeAppRestart="100">
You can also find some more information in this knowledge base article
. I hope it will help.
One of my colleagues sent me another link related to this problem and it is very useful – there are discussed all the reasons of this and also how to solve it. Here is the link: ASP.NET Case Study: Lost session variables and appdomain recycles