Skip to content

Dependency Injection KernelBuilder #6471

Closed Answered by stephentoub
CKThompson00 asked this question in Q&A
Discussion options

You must be logged in to vote

KernelBuilder is typically just for getting started in an environment that lacks its own DI container. The more typical real-app usage is in ASP.NET or Maui or Azure Functions or some other environment where there is a DI container, in which case you just integrate with that (e.g. the AddKernel extension for IServiceCollection). See https://youtu.be/jrNfKeGSuCg?t=179, and in particular starting at 15:56 (https://youtu.be/jrNfKeGSuCg?t=957). Kernel itself just wraps an arbitrary IServiceProvider, which can come from anywhere. If you use Kernel.CreateBuilder, that's creating a new standalone service collection that's then passed off to the built Kernel when you call Build. If you instead ju…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CKThompson00
Comment options

Answer selected by sophialagerkranspandey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants