Check and log multiple registrations of a same service in ASP.NET Core 3.1

added by DotNetKicks
1/20/2020 4:29:04 PM


Sometimes, the same service is registered in the ASP.NET Core dependency injection system. Sometimes by carelessness, sometimes by registering the instance yourself correctly, then a second time with automatic registration by scanning the assemblies. In my previous article here:, I showed how to unregister services, in this article I will show how to detect multiple registrations when starting the application.