Unable to resolve service for type 'Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckService'

0

I am trying to implement Health Check for ASP.net core.

public class BasicStartup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddHealthChecks();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.UseHealthChecks("/health");

        app.Run(async (context) =>
        {
            await context.Response.WriteAsync(
                "Navigate to /health to see the health status.");
        });
    }
}

System.InvalidOperationException

HResult=0x80131509

Message=Unable to resolve service for type 'Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckService' while attempting to activate 'Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckMiddleware'.

Source=Microsoft.AspNetCore.Http.Abstractions

StackTrace: at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_0.b__0(RequestDelegate next) at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build() at Microsoft.AspNetCore.Builder.MapWhenExtensions.MapWhen(IApplicationBuilder app, Func2 predicate, Action1 configuration) at Microsoft.AspNetCore.Builder.HealthCheckApplicationBuilderExtensions.UseHealthChecksCore(IApplicationBuilder app, PathString path, Nullable`1 port, Object[] args) at Microsoft.AspNetCore.Builder.HealthCheckApplicationBuilderExtensions.UseHealthChecks(IApplicationBuilder app, PathString path) at Coyote.Procurement.CasMat.Services.Api.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)

c#
asp.net
asp.net-core
asked on Stack Overflow Sep 6, 2019 by Haris Uddin • edited Sep 7, 2019 by Nkosi

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0