AppMetrics / AspNetCoreHealth

App Metrics Health Extensions for AspNet Core

Home Page:http://app-metrics.io/web-application-monitoring/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception registering JsonSerializerSettings conflicting with AppMetrics

alhardy opened this issue · comments

From @jchannon on December 4, 2017 19:52

public void ConfigureServices(IServiceCollection services)
{
  services.AddSingleton(new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() }, NullValueHandling = NullValueHandling.Ignore});
}

Using Autofac I got the below error:

Cannot choose between multiple constructors with equal length 1 on type 'App.Metrics.Formatters.Json.Serialization.HealthStatusSerializer'. Select the constructor explicitly, with the UsingConstructor() configuration method, when the component is registered.

Removing Autofac and just using ASP.NET DI I got a exception about HealthStatusserializer and I think IClock

Copied from original issue: AppMetrics/AspNetCore#4

App Metrics has never registered JsonSerializerSettings. The older version of HealthStatusSerializer had two ctors, one of which had JsonSerializerSettings injected so DI could not work out which ctor to use.

This is no longer the case