I did some consolidation of my NuGet packages across my solution and now I'm receiving:
exception message:
MissingMethodException: Method not found: 'System.IDisposable Serilog.Context.LogContext.Push(Serilog.Core.ILogEventEnricher)'.
call stack on the exception:
at Serilog.Extensions.Logging.SerilogLoggerProvider.BeginScope[T](T state) at Microsoft.Extensions.Logging.Logger.BeginScope[TState](TState state)
when I make a call like this:
using (logger.BeginScope(new Dictionary<string, object>
{
["SomeProperty"] = someVariable,
}))
{
logger.LogInfo("hello world");
}
package.config
<package id="Microsoft.Extensions.Logging" version="2.1.1" targetFramework="net48" />
<package id="Serilog" version="2.10.0" targetFramework="net48" />
<package id="Serilog.Extensions.Logging" version="3.0.1" targetFramework="net48" />
It would seem I have an incorrect NuGet reference but I'm not seeing it.
I also put together a full repro of the problem here.
As you already know, the issue is with the package Serilog.Enrichers.ClientInfo including an old version of
Serilog.dll
within the NuGet package, which is wrong (as it's supposed to be a dependency via NuGet only), thus the long-term fix is the maintainer fix that as you reported.A short-term fix, would be to manually edit your
.csproj
file to use the correctSerilog.dll
, from the Serilog package:Your repro project is pointing to the
Serilog.dll
that is inside of the Serilog.Enrichers.ClientInfo package:You can also add a post-build step that always copies the correct
Serilog.dll
to the output folder of your project.Update: This has been fixed in Serilog.Enrichers.ClientInfo v1.1.3.