Sitelet https://github.com/Microsoft/ApplicationInsights-dotnet/issues/755
Skip to content

(Minor Improvement) Guard TelemetryClient.Flush to not throw NullReference Exception #755

Description

Hi,
today I ran into an odd behavior that on app shutdown of my ASP.NET Core service, one part of the application (the Serilog Sink) tries to Flush before it disposes.
But at that point in time, this.configuration.TelemetryChannel in TelemetryClient is already null.

And that causes Flush to throw a hard NullReference Exception Code line 589

see serilog-contrib/serilog-sinks-applicationinsights#46

Could you just elvis the expression or at least null check it?

Thanks,
Michael

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions