Skip to content

Regression: ANCM: Unexpected application shutdown #58939

Open
@matbech

Description

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Starting with .NET 9 Preview 4 up to the current version of .NET 9 (9.0.100 with ANCM 19.0.24303.0) we are seeing unexpected application shutdowns (logged as "Application 'MACHINE/WEBROOT/APPHOST/WWW.BLA.COM/APPPOOLNAME' has shutdown.") after a certain time (usually a couple of hours). This results in the application being non-functional (503 http errors) until the IIS application pool is restarted or recycled.

The IIS application pool is configured with the following settings:
Idle time-out: 0
StartMode: AlwaysRunning.
Managed Pipeline mode: Integrated
Rapid Fail Protection - Enabled: false

OS: Windows Server 2022 (x64) and Windows Server 2025 (x64)

We have compiled the application with both, the .NET 9 Preview 3 SDK and with .NET 9.0.100 SDK with the same result when running it under a runtime / ANCM > .NET 9 Preview 3.

The issue does not happen with .NET 9 Preview 3 (runtime and ANCM). Maybe related to this issue #41340 and this commit #52807

No additional errors or informational messages (e.g. no application shutdowns due to recycle), or crash reports (WER) can be found in the event log.

The application is trivial. For illustration purpose, the simplified source code follows:

Program.cs

namespace Service
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
             .ConfigureWebHostDefaults(webBuilder =>
             {
                 webBuilder.UseStartup<Startup>();
             });
    }
}

Startup.cs


namespace Service
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
                options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter());
                options.InputFormatters.Add(new XmlDataContractSerializerInputFormatter(options));
            });
        }

        public void Configure(IApplicationBuilder app, IHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // managed by IIS
                // app.UseHsts();
            }

            // managed by IIS
            //app.UseHttpsRedirection();
            app.UseRouting();
            app.UseEndpoints(route =>
            {
                route.MapControllers();
            });
        }
    }
}

ActivationController.cs


namespace Service.Controllers
{
    [Route("v1")]
    [ApiController]
    public class ActivationController : ControllerBase, IDisposable
    {
        public ActivationController(ILogger<ActivationController> logger, IConfiguration configuration)
        {
            _logger = logger;
            _configuration = configuration;
        }
 
        public void Dispose()
        {
           // cleanup of db
        }

        [HttpPost]
        [Produces("application/xml")]
        public Business.Model.ActivationResponse Activate(Business.Model.ActivationRequest request)
        {
           ....
            return response;
        }

        [Route("deactivate")]
        [HttpPost]
        [Produces("application/xml")]
        public Business.Model.DeactivationResponse Deactivate(Business.Model.DeactivationRequest request)
        {
            ...
            return response;
        }

        private readonly ILogger _logger;
        private readonly IConfiguration _configuration;
        private MySqlConnection _licenseDatabase;
    }
}

Expected Behavior

No shutdown of the application. Application stays alive.

Steps To Reproduce

I'm only able to reproduce this in a production environment and it takes a random interval (hours) until it happens.

Exceptions (if any)

No response

.NET Version

9.0.100

Anything else?

dotnet --info

Host:
Version: 9.0.0
Architecture: x64
Commit: 9d5a6a9aa4
RID: win-x64

.NET SDKs installed:
No SDKs were found.

.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.0-preview.3.24172.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.feature-iisIncludes: IIS, ANCM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions