Ask questionsFailed to gracefully shutdown application (IIS Hang)

on application pool recycle (automatic by duration) and under high load i often get the following entry in event log Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/WEBNAME'.

this was already happen in 2.1 with outproc, but now i've updated to 2.2 with hostingModel="InProcess", but i get a additional eventlog entry:

CoreCLR Version: 4.6.27207.3
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.IOException: The handle is invalid
   at System.ConsolePal.WindowsConsoleStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.WriteLine(String value)
   at System.IO.SyncTextWriter.WriteLine(String value)
   at System.Console.WriteLine(String value)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.<>c__DisplayClass6_0.<AttachCtrlcSigtermShutdown>g__Shutdown|0()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.<>c__DisplayClass6_0.<AttachCtrlcSigtermShutdown>b__1(Object sender, EventArgs eventArgs)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.AppContext.OnProcessExit(Object sender, EventArgs e)

I use overlapped recycling, the new process is already stated, but i need to recycle manualy else the IIS is not processing requests anymore, they just timed out.


  • Windows Server 2012 R2
  • IIS 8.5
  • .net core runtime and hosting bundle 2.2.1
  • overlapped recycling enabled
  • web: preload enabled = true
  • application pool: start mode always running
  • 32bit application

any idea why this exception happens? the related code should be this (this Console.Log)


Answer questions deanward81

This is affecting us quite badly during local development under 2.2. We're running under IIS using the in-process model and everytime the app pool needs to recycle (usually due to actual changes made during development) a build fails because files are locked by the process crash being handled.

We have to stop the app pool in IIS, build and then restart - this is painful! Are there any known workarounds in 2.2?


Related questions

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies hot 8
MissingMethodException: Method not found Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder
Migrate Asp.Net Core 2.2 Integration Tests to 3.0 - The TestServer constructor was not called with a IWebHostBuilder so IWebHost is not available. hot 4
UseStaticFiles with StaticFileOptions/FileExtensionContentTypeProvider breaks server side Blazor hot 3
HTTP Error 500.30 - ANCM In-Process Start Failure hot 3
With core 3.0 SignInManager.IsSignedIn(User) allways reuturn false?but in 2.2 it works fine.Is that a debug? hot 3
CSS Isolation in Blazor Components hot 3
How to retrieve the HttpContext from Blazor server-side ? hot 3
Oauth2 authentication erroring with "The oauth state was missing or invalid." hot 3
BadHttpRequestException: Reading the request body timed out due to data arriving too slowly hot 2
HTTP Error 500.0 - ANCM In-Process Handler Load Failure hot 2
Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder`1.HasIndex(System.Linq.Expressions.Expression`1<System.Func`2<System.__Canon,System.Object>>)'. hot 2
MissingMethodException at SignInManager ctor after update hot 2
BadHttpRequestException: Reading the request body timed out due to data arriving too slowly hot 2
Github User Rank List