1

After pushing my code at work and then pulling it onto my home machine the next day, starting my web server threw the a null reference exception. This is caused on this line:

var requestTelemetry = context.GetRequestTelemetry();

where reqeuestTelemetry is null. Its possible to just continue and keep running the program, but every time the web server tries to do something, the error comes up.

My understanding is that this is related to the performance profiler. This would make sense as the last time I was using my home machine for this project, I was doing a bunch of performance diagnostics, and I had changed some of the settings. I also believe that the requestTelemetry line exists as part of the performance profiler code.

So here is what is troubling me the most. When I go to the performance profiler settings and disable everything, when I run the project it will always turn "CPU usage" on, no matter how I try to disable it. I've turned off enable sampling, I've turned off profiling when debugging altogether, nothing works.

What does seem to fix the null reference exception issue (but not the performance profiler issue) is setting "Enable just my code" in the Debugging options. I imagine this is just preventing me from seeing the error, rather than preventing the error from happening.

I've reviewed quite a few bug reports and nothing seems to match exactly, although there are some good insights.

https://github.com/microsoft/ApplicationInsights-dotnet/issues/1524

https://github.com/microsoft/ApplicationInsights-dotnet/issues/613

Visual Studio Debugger does not break on NullReferenceException, although checkbox is set in debugging options

My best guess is that there is some confusion between multiple profiler sessions between projects running at the same time?

pseudoabdul
  • 616
  • 3
  • 12

1 Answers1

0

Check your startup.cs and see if:

services.AddApplicationInsightsTelemetry();

Is included in your configure services block

Adam Weitzman
  • 1,552
  • 6
  • 23
  • 45