Graceful shutdown not work in .NetFramework image

Ronny Ren 6 Reputation points
2022-06-27T11:39:16.577+00:00

I have a Console application with .Net 6 and publish it with self-contained. This application needs graceful shutdown because it would be ran in a container that hosted in Kubernetes.

When I used .Net 6 runtime as base image (mcr.microsoft.com/dotnet/runtime:6.0), it worked well as expect. The ApplicationStopping, StopAsync and ApplicationStopped were triggered and logs displayed.
When I used .Net Framework as based image (mcr.microsoft.com/dotnet/framework/runtime:3.5, this is required for my application because some tools required it), it didn't work. Only ApplicationStopping was triggered and container was shutdown quickly even I set ShutdownTimeout to 60 seconds.

Is there any way to make it working in .Net framework?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,097 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.