serilog-extensions-logging icon indicating copy to clipboard operation
serilog-extensions-logging copied to clipboard

Upgrade Microsoft.Extensions.Logging or use abstraction.

Open niemyjski opened this issue 5 years ago • 7 comments
trafficstars

I'm getting a type load exception with 3.0.1 and I have no direct dependencies on Microsoft.Extensions.Logging The only dependency I can see is coming from this library. Currently only .NET Core 3.1 is supported (https://dotnet.microsoft.com/platform/support/policy/dotnet-core) would it be possible to bump deps with a new release?

System.TypeLoadException: Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
  at at Microsoft.Extensions.Logging.Logger.BeginScope[TState](TState state)
  at at Microsoft.Extensions.Logging.Logger`1.Microsoft.Extensions.Logging.ILogger.BeginScope[TState](TState state)

niemyjski avatar Apr 29 '20 12:04 niemyjski

Hi Blake, thanks for the note, which TFM are you targeting?

nblumhardt avatar Apr 29 '20 23:04 nblumhardt

Same issue as #158?

Numpsy avatar Apr 29 '20 23:04 Numpsy

Yes, the same issue #158 @niemyjski , it means the binary version of Microsoft.Extensions.Logging is different (<3.0.0) from .Abstractions version (3.1.3). Why it happens: Serilog.Extensions.Logging -> Microsoft.Extensions.Logging (2.0.0) -> Microsoft.Extensions.Logging.Abstractions (2.0.0) <LibraryProject> -> Microsoft.Extensions.Logging.Abstractions (3.1.3)

If you not add reference for Microsoft.Extensions.Logging package, the result of nuget dependency resolution will be: Microsoft.Extensions.Logging (2.0.0) Microsoft.Extensions.Logging.Abstractions (3.1.3)

I would suggest in this case if your library targets Abstractions package it is better for long term to target the least version possible unless you need specific API from higher version or have compatibility issues. Or add reference to Microsoft.Extensions.Logging (3.1.3) package to the end project

skomis-mm avatar Apr 30 '20 14:04 skomis-mm

Yep, same issue.

niemyjski avatar Apr 30 '20 14:04 niemyjski

Any updates on this?

niemyjski avatar Aug 26 '20 16:08 niemyjski

Any update on this?

bodisov avatar Dec 01 '20 03:12 bodisov

@skomis-mm Hi!

Thanks, your suggestion works fine for me 👍

abakumov-v avatar Feb 17 '21 12:02 abakumov-v

@nblumhardt close?

sungam3r avatar May 10 '23 05:05 sungam3r

Thanks @sungam3r 👍 fixed in #223

nblumhardt avatar May 10 '23 06:05 nblumhardt