Skip to content

Blazor WebAssembly app throws CircularDependencyException (ILoggerFactory) when calling AddBlazorClientServiceDefaults() #67032

@EmilyFeng97

Description

@EmilyFeng97

REGRESSION INFO: New feature on 11.0 P4

INSTALL STEPS:

  1. Clean Win 11 25h2 x64
  2. Install latest 11.0 Preview 5 build
  3. Apply Feed

Platform

  • Windows
  • macOS
  • Linux

Repro Steps

  1. Open up a normal Command Prompt (Terminal)

  2. Create a Blazor WebAssembly app

    mkdir MyBlazorApp
    cd MyBlazorApp
    dotnet new sln
    dotnet new blazorwasm -o MyBlazorApp
    dotnet sln add MyBlazorApp/MyBlazorApp.csproj
    
  3. Create a Blazor WebAssembly Service Defaults
    dotnet new blazor-wasm-servicedefaults -o MyBlazorApp.ServiceDefaults

  4. Add reference the library from the Blazor WebAssembly client.

    dotnet sln add MyBlazorApp.ServiceDefaults\MyBlazorApp.ServiceDefaults.csproj
    dotnet add MyBlazorApp/MyBlazorApp.csproj reference MyBlazorApp.ServiceDefaults/MyBlazorApp.ServiceDefaults.csproj
    
  5. Add the code in program.cs file of Blazor WebAssembly client app
    using MyBlazorApp;
    builder.AddBlazorClientServiceDefaults();

  6. Run the project

    cd MyBlazorApp
    dotnet run
    

Note

  1. This issue also repro when using: Aspire AppHost + Blazor WebAssembly (standalone) + Blazor WebAssembly ServiceDefaults.
  2. This issue does not repro when only configuring logging:
    builder.Logging.SetMinimumLevel(LogLevel.Information);

Actual Result
The project fails to load with error CircularDependencyException.
Image

blazor.webassembly.uv9pzyktbz.js:1 ManagedError: AggregateException_ctor_DefaultMessage (CircularDependencyException, Microsoft.Extensions.Logging.ILoggerFactory)
callEntryPoint @ blazor.webassembly.uv9pzyktbz.js:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions