✅ BuildServiceProvider does not exist
everyone i can find online says this is how to get an instance of IServiceProvider, but it does not work. i found one person with my issue, but they had the wrong useing declaration.
7 Replies
IServiceCollection
is a... collection of services
What would "building" it entail?i am not realy sure. i dont actualy know what this does, i am trying to hack together a discord bot and this is part of what chatGPT spit out.
uses include:
and
looking into alternitive data types for these params...
it doesent like ServiceCollection... and i am lost after that
I recommend checking the documentation of whatever bot library it is you're using, rather than relying on an LLM to provide accurate information
generally you would inject IServiceProvider from a constructor
don't call BuildServiceProvider, there should be an instance already (at least that you know what you are doing)
ideally you would want to inject the service you need instead of the IServiceProvider itself, anyway
i did eventualy figure it out. still not sure what i did, but i rebuilt it like 3 times based on a few articles and the docs and the last one worked
that's a, uhm, empirical approach, maybe? but ok
yea everyone sets it up differently and no one comments their code properly >:(
or even explanes why they do what they do
very annoying
no one writes code for people who like learning by building a project. but i guess thats a me problem