dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.21k stars 4.72k forks source link

Windows Service Error 1053 #77861

Closed Phylum123 closed 1 year ago

Phylum123 commented 1 year ago

Description

I created a windows service, by using the worker project template and then referencing the extension.windowsservice Nuget package. I added UseWindowsService to the host creation. Without any changes I deployed the default service using SC.exe and it worked just fine. I then added some logic to the worker and updated the program.cs to load a few more things. The whole startup is around 800ms. I run the program in debug mode and it works as expected. However, when I try to use the new version as a target of SC, it installs but won't start due to error 1053. The weird part is the error comes up almost immediately, it is not waiting 30 seconds. Checking the event log I get two events - 7000, 7009. Event 7009 verifies the time out is set to 30 seconds (30,000ms).

The second weird part is that if I just execute the exe, all is well and it runs as expected, except with a console window.

Is there any way to get a more meaningful message or something else I can try to figure out why it is not working as a windows service?

Below is the project file.

<Project Sdk="Microsoft.NET.Sdk.Worker">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <UserSecretsId>dotnet-CIIS.Pario2.DataBridge.HostedServiceTest-9B2416D7-E562-47A1-B37D-22D6F1BA0810</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
    <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\CIIS.Pario2.Common.Service\CIIS.Pario2.Common.Service.csproj" />
    <ProjectReference Include="..\CIIS.Pario2.DataBridge.DomainServices\CIIS.Pario2.DataBridge.DomainServices.csproj" />
  </ItemGroup>
</Project>

Reproduction Steps

See above

Expected behavior

The program to function as a windows service.

Actual behavior

Error 1053

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/area-extensions-hosting See info in area-owners.md if you want to be subscribed.

Issue Details
### Description I created a windows service, by using the worker project template and then referencing the extension.windowsservice Nuget package. I added UseWindowsService to the host creation. Without any changes I deployed the default service using SC.exe and it worked just fine. I then added some logic to the worker and updated the program.cs to load a few more things. The whole startup is around 800ms. I run the program in debug mode and it works as expected. However, when I try to use the new version as a target of SC, it installs but won't start due to error 1053. The weird part is the error comes up almost immediately, it is not waiting 30 seconds. Checking the event log I get two events - 7000, 7009. Event 7009 verifies the time out is set to 30 seconds (30,000ms). The second weird part is that if I just execute the exe, all is well and it runs as expected, except with a console window. Is there any way to get a more meaningful message or something else I can try to figure out why it is not working as a windows service? Below is the project file. ``` net6.0 enable enable dotnet-CIIS.Pario2.DataBridge.HostedServiceTest-9B2416D7-E562-47A1-B37D-22D6F1BA0810 ``` ### Reproduction Steps See above ### Expected behavior The program to function as a windows service. ### Actual behavior Error 1053 ### Regression? _No response_ ### Known Workarounds _No response_ ### Configuration _No response_ ### Other information _No response_
Author: Phylum123
Assignees: -
Labels: `untriaged`, `area-Extensions-Hosting`
Milestone: -
Phylum123 commented 1 year ago

Can anyone look at this?

tarekgh commented 1 year ago

We'll get into this when we are triaging it. And please provide a complete sample reproducing the issue we can look at.

ghost commented 1 year ago

This issue has been marked needs-author-action and may be missing some important information.

ghost commented 1 year ago

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

ghost commented 1 year ago

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.