MajMcCloud / TelegramBotFramework

This is a context based application framework for the C# TelegramBot library.
https://www.t.me/tgbotbase
MIT License
149 stars 43 forks source link

Incorrect overwriting of an error message during resolving dependencies #62

Open nktdrkhv opened 6 months ago

nktdrkhv commented 6 months ago

If we register a dependency incorrectly, so BotBase can't resolve it, we won't get a correct error message.

The problem happens at SessionManager.cs / StartSession Method 62 line

var start = BotBase.StartFormFactory.CreateForm();

and then at ServiceProviderStartFormFactory.cs / 27 line

var fb = (FormBase)ActivatorUtilities.CreateInstance(_serviceProvider, _startFormClass);

We should recieve "Cannot resolve scoped service 'X' from root provider." but insted we get System.NullReferenceException: Object reference not set to an instance of an object.

MajMcCloud commented 6 months ago

That fix should work for it. For now it is added to the development branch.