TelegramBots/Telegram.Bot.Examples

When i use your example in NET6 Telegram.Bot.Examples.Polling

andreyshiryaev opened this issue · 4 comments

Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostedService Lifetime: Singleton ImplementationType: TelegramBot.Client.PollingService': Cannot consume scoped service 'TelegramBot.Client.UpdateHandlers' from singleton 'Microsoft.Extensions.Hosting.IHostedService'.)'

image

if using UpdateHandlers as Singleton is Ok.
But I am not sure that it is correct.

services.AddSingleton();

Good catch, I'm trying to fix this.
Though singleton would fix the dependency issue, it renders all the ceremony around typed HttpClient useless.

@andreyshiryaev can you confirm the issue is resolved now?

@andreyshiryaev can you confirm the issue is resolved now?

@karb0f0s yes, it is Ok now. I'm sorry for the long answer it was not a priority task for me

@karb0f0s I'm trying to get my head around your example code. Could you explain why using a singleton would render the ceremony around typed HttpClient useless?