dotnet / dotnet/AspNetCore.Docs

"Another service locator variation to avoid is injecting a factory that resolves dependencies at runtime."

Open
#22,328 0 comments 1 reaction 0 assignees View on GitHub
doc-enhancement re-Aditya Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

Then the very first item in [framework provided services](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.0#framework-provided-services) is a factory, along with two (three if you count the *Provider).

When is it considered acceptable (or not) to use a factory?

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 0d78f540-81fd-1ba9-cb90-591e4ec27d9b
* Version Independent ID: 2251f557-dd3a-ec35-2558-6243337db009
* Content: [Dependency injection in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.0#default-service-container-replacement)
* Content Source: [aspnetcore/fundamentals/dependency-injection.md](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/dependency-injection.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-fundamentals**
* GitHub Login: @Rick-Anderson
* Microsoft Alias: **riande**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.