fsprojects / fsprojects/Paket

UseWindowsService() - The process was terminated due to an unhandled exception.

Open
#4,167 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
F#
Stars
2.1k
Forks
528
Avg merge
1d 12m
Merged PRs (30d)
54

Description

I started a gRPC project from Visual Studio 2022 with .Net 6.0.

Steps:

  1. Microsoft.Extensions.Hosting.WindowsServices (6.0.0)
  2. Add this line to program.cs builder.Host.UseWindowsService();
  3. Build the project
  4. Created a Window Service with the sc command:

sc create "Grpc Test2" binPath= C:\Users\WuJ22\source\repos\GrpcService1\GrpcService1\bin\Release\net6.0\GrpcService1.exe start= auto DisplayName= "Grpc Test2"

Please provide a succinct description of your issue.

  1. The service failed to start
  2. Event log has this message:

Application: GrpcService1.exe
CoreCLR Version: 6.0.622.26707
.NET Version: 6.0.6
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NotSupportedException: The content root changed from "C:\Windows\system32" to "C:\Users\WuJ22\source\repos\GrpcService1\GrpcService1\bin\Release\net6.0". Changing the host configuration using WebApplicationBuilder.Host is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.
at Microsoft.AspNetCore.Builder.ConfigureHostBuilder.ConfigureHostConfiguration(Action1 configureDelegate) at Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.UseContentRoot(IHostBuilder hostBuilder, String contentRoot) at Microsoft.Extensions.Hosting.WindowsServiceLifetimeHostBuilderExtensions.UseWindowsService(IHostBuilder hostBuilder, Action1 configure)
at Program.

$(String[] args) in C:\Users\WuJ22\source\repos\GrpcService1\GrpcService1\Program.cs:line 9

Expected behavior
  1. Service to start without error
Actual behavior
  1. Service wouldn't start

None at the moment

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced Program.cs line 9 and the UseWindowsService call in a .NET 6 gRPC project. Reproduce the service startup using the sc command and inspect the hosting configuration exception and related Windows service hosting behavior. Done means the service starts without the reported unhandled exception, with a regression test or documented reproduction if the project supports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, grpc
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.