Answers for "c# system.invalidoperationexception: unable to resolve service for type"

C#
1

System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger`1

public void ConfigureServices(IServiceCollection services)
    {
        var serviceProvider = services.BuildServiceProvider();
        var logger = serviceProvider.GetService<ILogger<AnyClass>>();
        services.AddSingleton(typeof(ILogger), logger);
        ...
     }
Posted by: Guest on November-28-2020

Code answers related to "c# system.invalidoperationexception: unable to resolve service for type"

C# Answers by Framework

Browse Popular Code Answers by Language