From 63309db7d94406aef0e1c4cb4626665e03348835 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Sun, 19 Nov 2023 15:00:33 +0100 Subject: [PATCH] fix: service didn't use created singleton --- Server/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Server/Program.cs b/Server/Program.cs index e203b3b..0c67d9b 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -42,7 +42,8 @@ builder.Services.AddDbContextPool(o => builder.Services.AddSingleton(loggerFactory); builder.Services.AddSingleton(); builder.Services.AddSingleton(); -builder.Services.AddHostedService(); +builder.Services.AddHostedService(provider => + provider.GetService() ?? throw new InvalidOperationException()); builder.Services.AddHostedService(provider => provider.GetService() ?? throw new InvalidOperationException()); builder.Services.AddMassTransit(x =>