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.

useful!

Related questions

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies hot 6
ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY when clean webapi template
MissingMethodException: Method not found Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder
Migrate Asp.Net Core 2.2 Integration Tests to 3.0 - The TestServer constructor was not called with a IWebHostBuilder so IWebHost is not available. hot 4
HTTP Error 500.30 - ANCM In-Process Start Failure hot 3
CSS Isolation in Blazor Components hot 3
How to retrieve the HttpContext from Blazor server-side ? hot 3
Oauth2 authentication erroring with "The oauth state was missing or invalid." hot 3
Failed to gracefully shutdown application (IIS Hang) hot 3
UseStaticFiles with StaticFileOptions/FileExtensionContentTypeProvider breaks server side Blazor hot 2
HTTP Error 500.0 - ANCM In-Process Handler Load Failure hot 2
Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder`1.HasIndex(System.Linq.Expressions.Expression`1<System.Func`2<System.__Canon,System.Object>>)'. hot 2
MissingMethodException at SignInManager ctor after update hot 2
BadHttpRequestException: Reading the request body timed out due to data arriving too slowly hot 2
.NET Core 3 Preview Blazor basic project does not compile hot 2
Github User Rank List