diff --git a/src/Serilog/Context/LogContext.cs b/src/Serilog/Context/LogContext.cs index 1be79e705..d5c61e070 100644 --- a/src/Serilog/Context/LogContext.cs +++ b/src/Serilog/Context/LogContext.cs @@ -253,10 +253,8 @@ public DisposableObjectHandle(object o) : base(o) public override object InitializeLifetimeService() { - var lease = (ILease)base.InitializeLifetimeService(); - // ReSharper disable once PossibleNullReferenceException - // not 100% sure this will never occur ... - lease.Register(LifeTimeSponsor); + var lease = base.InitializeLifetimeService() as ILease; + lease?.Register(LifeTimeSponsor); return lease; }