A timeout was reached (60000 milliseconds) while waiting for the My Test Service service to connect.

Shawn Lien 21 Reputation points
2023-01-05T08:10:10.533+00:00

Hi teams:

I created a Worker Service project using Visual Studio 2022.
276403-image-20230105133752.jpg

276367-image-20230105134114.jpg

276339-image-20230105134129.jpg

I refer to this document to publish the project template and create a widows service.
https://learn.microsoft.com/zh-tw/dotnet/core/extensions/windows-service
276188-image-20230105134239.jpg

276189-image-20230105134259.jpg

276266-image-20230105134409.jpg

276220-image-20230105134713.jpg

But when starting the service I always get the error:
276376-image-20230105134858.jpg

The My Test Service service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.
276328-image-20230105135006.jpg

A timeout was reached (60000 milliseconds) while waiting for the My Test Service service to connect.
276411-image-20230105135023.jpg

But when debugging from Visual Studio or directly executing the exe file, the program execution is correct.
276358-image-20230105152859.jpg

276431-image-20230105152935.jpg

What is the problem?
Thanks.

Developer technologies | .NET | .NET Runtime
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.9K Reputation points
    2023-01-05T08:26:44.87+00:00

    Maybe you should use await host.RunAsync( ) according to documentation. Also add async to Main, or create a new project that does not contain the Main function. (Do not select the "Do not use top-level statements" option).

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.