Base solution for your next web application
Open Closed

Exception due to HealthChecks in a brand new project #10920


User avatar
0
bluescopesteel created

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? 11.0
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)?.net core

I am getting exception due to HealthChecks in a brand new project!

If I use

"HealthChecks": {
    "HealthChecksEnabled": **true**,
    "HealthChecksUI": {
      "HealthChecksUIEnabled": **true**,
      "HealthChecks": [
        {
          "Name": "MyProd.Web.Host",
          "Uri": "https://localhost:44301/health"
        }
      ],
      "EvaluationTimeOnSeconds": 10,
      "MinimumSecondsBetweenFailureNotifications": 60
    }
  },

Exception is:

An error occurred while starting the application.
TypeLoadException: Method 'GetServiceProviderHashCode' in type 'ExtensionInfo' from assembly 'Microsoft.EntityFrameworkCore.InMemory, Version=5.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
Microsoft.EntityFrameworkCore.InMemory.Infrastructure.Internal.InMemoryOptionsExtension.get_Info()

ComponentActivatorException: ComponentActivator: could not instantiate HealthChecks.UI.Core.Data.HealthChecksDb
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, object[] arguments, Type implType)

TypeLoadException: Method 'GetServiceProviderHashCode' in type 'ExtensionInfo' from assembly 'Microsoft.EntityFrameworkCore.InMemory, Version=5.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
Microsoft.EntityFrameworkCore.InMemory.Infrastructure.Internal.InMemoryOptionsExtension.get_Info()
Microsoft.EntityFrameworkCore.DbContextOptions.GetHashCode()
System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>.GetOrAdd<TArg>(TKey key, Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument)
Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, bool providerRequired)
Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
lambda_method1208(Closure , object[] )
Castle.Core.Internal.ReflectionUtil.Instantiate(ConstructorInfo ctor, object[] ctorArgs)
Castle.Core.Internal.ReflectionUtil.Instantiate<TBase>(Type subtypeofTBase, object[] ctorArgs)
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, object[] arguments, Type implType)

Show raw exception details
ComponentActivatorException: ComponentActivator: could not instantiate HealthChecks.UI.Core.Data.HealthChecksDb
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, object[] arguments, Type implType)
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, object[] arguments)
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, bool trackedExternally)
Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.<>n__0(CreationContext context, bool trackedExternally)
Castle.MicroKernel.Lifestyle.ScopedLifestyleManager+<>c__DisplayClass4_0.<Resolve>b__0(Action<Burden> afterCreated)
Castle.MicroKernel.Lifestyle.Scoped.DefaultLifetimeScope.GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance)
Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
Castle.Windsor.MsDependencyInjection.MsScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, bool requiresDecommission, bool instanceRequired, out Burden burden)
Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, bool instanceRequired)
Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, Arguments additionalArguments, IReleasePolicy policy, bool ignoreParentContext)
Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, Arguments arguments, IReleasePolicy policy, bool ignoreParentContext)
Castle.MicroKernel.DefaultKernel.Resolve(Type service, Arguments arguments)
Castle.Windsor.WindsorContainer.Resolve(Type service)
Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.ResolveInstanceOrNull(Type serviceType, bool isOptional)
Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetServiceInternal(Type serviceType, bool isOptional)
Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetRequiredService(Type serviceType)
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService<T>(IServiceProvider provider)
HealthChecks.UI.Core.HostedService.UIInitializationHostedService.InitializeDatabase(IServiceProvider sp)
HealthChecks.UI.Core.HostedService.UIInitializationHostedService.StartAsync(CancellationToken cancellationToken)
Microsoft.AspNetCore.Hosting.HostedServiceExecutor.ExecuteAsync(Func<IHostedService, Task> callback, bool throwOnFirstFailure)
Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, string startupMessage)
Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, string startupMessage)
Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
endurohub.Web.Startup.Program.Main(string[] args) in Program.cs
+
            CreateWebHostBuilder(args).Build().Run();

I tried to move to latest version, couple of other changes in appsettings.json, but same issue.


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please follow https://github.com/aspnetzero/aspnet-zero-core/issues/4260. This will be fixed soon.

  • User Avatar
    0
    bluescopesteel created

    Hi @ismcagdas,

    Thanks v much.

    Can you please give us the steps to fix in 11.0.0 as well?

    We recently migrated from 10.4.0 to 11.0.0, so we don't have any plan to change it to v11.2.0 soon.

  • User Avatar
    0
    musa.demir created

    Hi @bluescopesteel

    You can follow the progress in https://github.com/aspnetzero/aspnet-zero-core/issues/4260. We will link the related pull-request to the issue when it is fixed. Then you can do same fix to your project.

  • User Avatar
    1
    bluescopesteel created

    Thanks v much @musa.demir

  • User Avatar
    0
    ismcagdas created
    Support Team

    Closing the issue since it is tracked by https://github.com/aspnetzero/aspnet-zero-core/issues/4260