1

I've tried to start the AspNetCore.HealthCheckier.UI with the .Net Core 6 like so:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddHealthChecksUI().AddInMemoryStorage();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (builder.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}
else
{
    app.UseExceptionHandler("/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
    endpoints.MapHealthChecksUI();
    endpoints.MapRazorPages();
});

app.Run();

But I get some incomprehensible error when I reach app.run:

System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable1 source, Func2 predicate, Boolean& found) at System.Linq.Enumerable.Single[TSource](IEnumerable1 source, Func2 predicate) at Microsoft.EntityFrameworkCore.Query.QueryableMethods..cctor()

enter image description here

Any idea? I cannot run exact same syntax in .Net Core 5, but similar code does work in .Net Core 5.

  • 1
    If you are using [this one](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks) currently it says _"ASP.NET Core versions supported: 5.0, 3.1, 3.0 and 2.2"_. Check out the [preview versions](https://www.nuget.org/packages/AspNetCore.HealthChecks.UI/6.0.1-rc2.4) (i.e. `dotnet add package AspNetCore.HealthChecks.UI --version 6.0.1-rc2.4`, or enable preview versions in VS Nuget Manager), I guess they will support 6.0. – Guru Stron Nov 11 '21 at 21:11

0 Answers0