ASP.NET Core: Can not resolve a service instance through CallContextServiceLocator.Locator.ServiceProvider
<p>This is part of my <code>ConfigureServices</code> method: </p>

<pre><code>public void ConfigureServices(IServiceCollection services)
{
    ...

    //bus
    services.AddSingleton&lt;IRouteMessages, MessageRouter&gt;();
    services.AddSingleton&lt;IBus, DirectBus&gt;();
    ////

   ...

}
</code></pre>

<p>I'm trying to resolve the instance of <code>IRouteMessages</code> interface in my <code>RegisterCommandHandlersInMessageRouter</code> class:</p>

<pre><code>public class RegisterCommandHandlersInMessageRouter
{
    ...

    public static void BootStrap()
    {
        var router = CallContextServiceLocator.Locator.ServiceProvider.GetService(typeof (IRouteMessages));
        new RegisterCommandHandlersInMessageRouter().RegisterRoutes(router as MessageRouter);
    }

    ...

}
</code></pre>

<p><code>router</code> variable is always null. Yet in my controllers where <code>IRouterMessages</code> is resolved automatically (in constructors) everything is fine. </p>

<p>I'm not sure what other parts of my code could be useful. I will provide more details. </p>