BlazorExtensions / Logging

Microsoft Extension Logging implementation for Blazor
MIT License
216 stars 31 forks source link

InvalidOperationException in preview7 #34

Closed seanmorangsp closed 5 years ago

seanmorangsp commented 5 years ago

This happens both on a new webapplication1 type project as well as a project with a busy Startup.cs.

The Startup code is:

        services.AddLogging(builder => builder
            .AddBrowserConsole()
            .SetMinimumLevel(LogLevel.Trace)
        );

and it eventually blows up in program.cs as

InvalidOperationException: Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostApplicationLifetime Lifetime: Singleton ImplementationType: Microsoft.Extensions.Hosting.Internal.ApplicationLifetime': Cannot consume scoped service 'Microsoft.JSInterop.IJSRuntime' from singleton 'Microsoft.Extensions.Logging.ILogger`1[Microsoft.Extensions.Hosting.Internal.ApplicationLifetime]'.

Removing the code block eliminates the error, and all logging functionality.

galvesribeiro commented 5 years ago

Hi!

The loggings are all working on preview 7:

image image image

jasonvasquez commented 5 years ago

I'm still investigating, but, for what it's worth, I'm having the exact issue as the original report. This is just from a brand new install, and latest Blazor.Extensions.Logging from NuGet

Here's the relevant version info from .csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>7.3</LangVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Blazor.Extensions.Logging" Version="0.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview7.19365.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview7.19365.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview7.19365.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview7.19362.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview7.19362.6" />
  </ItemGroup>

</Project>
galvesribeiro commented 5 years ago

Can you clone the repo, run the test project and see if the problem is happening? Otherwise I can't reproduce the problem here.

galvesribeiro commented 5 years ago

Please try again with preview9. I'm unable to reproduce it and there is no activity here, so I'm closing the issue.