Skip to main content
InterviewHubPRO
Section Overview
Q49

Question 49 of 50

Part 3: CLR Internals, Native AOT & Production Diagnostics (25 - 35)

98%
C# & CLR Internals (50 Qs)•Part 3: CLR Internals, Native AOT & Production Diagnostics (25 - 35)

Dependency Injection: The Captive Dependency Problem.

senior LevelMost AskedDependency Injection

In Simple Words: .NET provides three DI lifetimes:

  1. Transient: Created every time requested.
  2. Scoped: Created once per client request (HTTP request).
  3. Singleton: Created once for the application lifetime.
  • The Captive Dependency Bug: If a Singleton service injects a Scoped service (like an EF Core DbContext), the scoped service is kept alive forever by the singleton! This leads to memory leaks, concurrency crashes, and reading stale database state.