profile
viewpoint

Ask questionsASP.NET Core 3.0 Blazor Server app does not start when adding browser logging

I'm trying to add the BlazorExtension.Logging library to my ASP.NET Core 3.0 application and I'm getting the following error that suggests some circular dependency issue between IJSRuntime and BrowserConsoleLogger:

System.AggregateException
  HResult=0x80131500
  Message=Some services are not able to be constructed
  Source=Microsoft.Extensions.DependencyInjection
  StackTrace:
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable`1 serviceDescriptors, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
   at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter`1.CreateServiceProvider(Object containerBuilder)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at CareSwitch.Program.<Main>d__0.MoveNext() in C:\Users\MarkFayngersh\source\repos\CareSwitch Blazor\Program.cs:line 18

Inner Exception 1:
InvalidOperationException: Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostApplicationLifetime Lifetime: Singleton ImplementationType: Microsoft.Extensions.Hosting.Internal.ApplicationLifetime': A circular dependency was detected for the service of type 'Microsoft.JSInterop.IJSRuntime'.
Microsoft.Extensions.Hosting.IHostApplicationLifetime(Microsoft.Extensions.Hosting.Internal.ApplicationLifetime) -> Microsoft.Extensions.Logging.ILogger<Microsoft.Extensions.Hosting.Internal.ApplicationLifetime>(Blazor.Extensions.Logging.BrowserConsoleLogger<Microsoft.Extensions.Hosting.Internal.ApplicationLifetime>) -> Microsoft.JSInterop.IJSRuntime(Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime) -> Microsoft.Extensions.Logging.ILogger<Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime>(Blazor.Extensions.Logging.BrowserConsoleLogger<Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime>) -> Microsoft.JSInterop.IJSRuntime

Inner Exception 2:
InvalidOperationException: A circular dependency was detected for the service of type 'Microsoft.JSInterop.IJSRuntime'.
Microsoft.Extensions.Hosting.IHostApplicationLifetime(Microsoft.Extensions.Hosting.Internal.ApplicationLifetime) -> Microsoft.Extensions.Logging.ILogger<Microsoft.Extensions.Hosting.Internal.ApplicationLifetime>(Blazor.Extensions.Logging.BrowserConsoleLogger<Microsoft.Extensions.Hosting.Internal.ApplicationLifetime>) -> Microsoft.JSInterop.IJSRuntime(Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime) -> Microsoft.Extensions.Logging.ILogger<Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime>(Blazor.Extensions.Logging.BrowserConsoleLogger<Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime>) -> Microsoft.JSInterop.IJSRuntime

Error goes away as soon as I remove the call to .AddBrowserConsole().

Versions

  • ASP.NET Core Blazor Server app - v3.0.0
  • Blazor.Extensions.Logging - v1.0.0
aspnet/AspNetCore

Answer questions pheuter

Noticed the blazor-wasm tag was added, just wanted to clarify that this is only an issue when using the Server hosted model. It appears to work fine when using wasm.

Related questions

ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY when clean webapi template hot 292
Restore MvcJsonOptions to ASP.NET Core 3.0 as a type forward? hot 272
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies hot 271
The SPA default page middleware could not return the default page '/index.html' in production application hot 173
HTTP Error 500.30 - ANCM In-Process Start Failure hot 156
HTTP Error 500.30 - ANCM In-Process Start Failure hot 149
Calling Request.EnableRewind throw on 3.0.0-preview7 hot 128
ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY when clean webapi template hot 121
Issue with BuildServiceProvider() in ConfigureServices() hot 116
DataProtection - CryptographicException when using EntityFramework as Key Storage Provider hot 109
Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing. To continue using 'UseMvc', please set 'MvcOptions.EnableEndpointRounting = false' inside 'ConfigureServices'. hot 103
Error: Server returned handshake error: Handshake was canceled. hot 95
IIS in-process hosting incorrectly throws ConnectionResetException for HTTP POST hot 91
Blazor - rzc generate exited with code 1. DotNet Core 3.0.100-preview8-013656 hot 89
error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback' hot 88
Github User Rank List