This repository contains code to reproduce issue when .NET 6 based Windows service occasionaly fails to stop gracefully.
- Publish the test application using VS 2022 or by running
dotnet publish -c release --self-contained -r win-x64
inTestApp
folder - Create a new Windows service by executing
sc create ".NET6 Test" binpath={PathToPublishedExe}
as administrator - Execute the Powershell script
repro.ps1
to start restarting the service. The script relly on the service name being.NET6 Test
when other service name is chosen the script must be edited - Watch for errors in the event log =>
Windows Logs -> System
there will be message like this:The .NET6 Test service terminated unexpectedly. It has done this 3 time(s).