Avoiding the Captive Dependency: Mastering .NET Core DI Lifetimes
Learn how to identify and fix 'Captive Dependencies' in .NET Core by correctly implementing Transient, Scoped, and Singleton lifetimes to prevent memory leaks.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to identify and fix 'Captive Dependencies' in .NET Core by correctly implementing Transient, Scoped, and Singleton lifetimes to prevent memory leaks.
The .NET Generic Host transforms simple console apps into configurable, maintainable services. Learn how to use it for CLI tools with dependency injection, logging, and graceful shutdown handling.
When a NestJS service grows to support many tenants, configuration drift can explode. Dynamic modules let you generate per‑tenant providers at bootstrap, keeping core logic untouched and tests simple.
Use .NET Core DI lifetimes as trust boundaries. Keep DbContext Scoped per request, avoid captive dependencies with Singleton services, and create explicit scopes for background work. Validate with ValidateScopes and scope identity tests.
Learn how Symfony autowiring resolves dependencies via type-hints to eliminate boilerplate, and how to handle ambiguous services using the debug:autowiring tool.
Stop choosing between socket exhaustion and stale DNS. Learn how IHttpClientFactory manages the HttpClient lifecycle in .NET to ensure high-performance, resilient API integrations.
Learn how Scala 3's given and using clauses replace the overloaded implicit keyword to provide clearer dependency injection and type-class resolution.
Enable Symfony's autowiring and autoconfiguration to let the service container inject dependencies via constructor type hints. This guide shows the configuration, a concrete NewsletterManager example, limits like ambiguous interfaces, and verification commands.
Learn to configure Laminas ServiceManager v3 with factories and delegators, avoid circular dependencies, and understand configuration merging quirks in modular applications.