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

154 Views

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: http://anthonygiretti.com/2020/01/20/remove-unwanted-instances-from-servicecollection-in-asp-net-core-3-1/, I showed how to unregister services, in this article I will show how to detect multiple registrations when starting the application.


0 comments