Problem guide

Detect TryAdd And Duplicate Registration Misuse

This page targets teams debugging confusing registration order issues and silent overrides in service composition code.

When this page is relevant

Catch ignored TryAdd calls and duplicate registrations that change single-service resolution behavior in Microsoft.Extensions.DependencyInjection.

Recommended install command

dotnet add package DependencyInjection.Lifetime.Analyzers --version 2.2.2

Relevant diagnostics

The rules that cover this failure mode