Skip to content

NullReferenceExeption in Microsoft.AI.Web RequestTrackingTelemetryModule in 2.23.0 #2980

@daiplusplus

Description

@daiplusplus
    <PackageReference Include="Microsoft.ApplicationInsights"                      Version="2.23.0"      />
    <PackageReference Include="Microsoft.ApplicationInsights.Web"                  Version="2.23.0"      />
  • Runtime version: net48
  • Hosting environment: Local debugging

Describe the bug

Shortly after starting my ASP.NET WebForms 4.8 application in the VS 2022 debugger, VS reports a NullReferenceExeption thrown from within Microsoft.AI.Web.dll!Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule.AddTargetHashForResponseHeader:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.AI.Web
  StackTrace:
   at Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule.AddTargetHashForResponseHeader(HttpContext context) in /_/WEB/Src/Web/Web/RequestTrackingTelemetryModule.cs:line 209

The full stack-trace reported in VS's Call Stack window is:

Microsoft.AI.Web.dll!Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule.AddTargetHashForResponseHeader(System.Web.HttpContext context = {System.Web.HttpContext}) Line 209
	at /_/WEB/Src/Web/Web/RequestTrackingTelemetryModule.cs(209)
Microsoft.AI.Web.dll!Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule..ctor.AnonymousMethod__9_0(System.Web.HttpContext httpContext = {System.Web.HttpContext}) Line 81
	at /_/WEB/Src/Web/Web/ApplicationInsightsHttpModule.cs(81)
System.Web.dll!System.Web.HttpResponse.UpdateNativeResponse.AnonymousMethod__289_0(System.Action<System.Web.HttpContext> cb = {Method = {System.Reflection.RuntimeMethodInfo}})
System.Web.dll!System.Web.Util.SubscriptionQueue<System.Action<System.Web.HttpContext>>.FireAndComplete(System.Action<System.Action<System.Web.HttpContext>> action = {Method = {System.Reflection.RuntimeMethodInfo}})
System.Web.dll!System.Web.HttpResponse.UpdateNativeResponse(bool sendHeaders = true)
System.Web.dll!System.Web.HttpResponse.Flush(bool finalFlush = false, bool async = false)
System.Web.dll!System.Web.HttpResponse.Flush()
System.Web.dll!System.Web.HttpWriter.WriteFromStream(byte[] data = {byte[25]}, int offset = 0, int size = 25)
System.Web.dll!System.Web.HttpResponseStream.Write(byte[] buffer = {byte[25]}, int offset = 0, int count = 25)
Microsoft.Owin.Host.SystemWeb.dll!Microsoft.Owin.Host.SystemWeb.CallStreams.DelegatingStream.Write(byte[] buffer = {byte[25]}, int offset = 0, int count = 25) Line 151
	at /_/src/Microsoft.Owin.Host.SystemWeb/CallStreams/DelegatingStream.cs(151)
Microsoft.Owin.Host.SystemWeb.dll!Microsoft.Owin.Host.SystemWeb.CallStreams.OutputStream.Write(byte[] buffer = {byte[25]}, int offset = 0, int count = 25) Line 52
	at /_/src/Microsoft.Owin.Host.SystemWeb/CallStreams/OutputStream.cs(52)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.Owin.ServerResponse.Write(System.ArraySegment<byte> data = {System.ArraySegment<byte>}) Line 46
	at /_/src/Microsoft.AspNet.SignalR.Core/Owin/ServerResponse.cs(46)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.Hosting.ResponseExtensions.End(Microsoft.AspNet.SignalR.Hosting.IResponse response = {Microsoft.AspNet.SignalR.Owin.ServerResponse}, string data = "{ \"Response\": \"started\" }") Line 32
	at /_/src/Microsoft.AspNet.SignalR.Core/Hosting/ResponseExtensions.cs(32)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.PersistentConnection.SendJsonResponse(Microsoft.AspNet.SignalR.Hosting.HostContext context = {Microsoft.AspNet.SignalR.Hosting.HostContext}, string jsonPayload = "{ \"Response\": \"started\" }") Line 548
	at /_/src/Microsoft.AspNet.SignalR.Core/PersistentConnection.cs(548)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.PersistentConnection.ProcessStartRequest.AnonymousMethod__79_0(Microsoft.AspNet.SignalR.Hosting.HostContext c = {Microsoft.AspNet.SignalR.Hosting.HostContext}) Line 537
	at /_/src/Microsoft.AspNet.SignalR.Core/PersistentConnection.cs(537)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.TaskAsyncHelper.GenericDelegates<object, System.Threading.Tasks.Task, Microsoft.AspNet.SignalR.Hosting.HostContext, object, object>.ThenWithArgs.AnonymousMethod__0() Line 1332
	at /_/src/Microsoft.AspNet.SignalR.Core/TaskAsyncHelper.cs(1332)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.TaskAsyncHelper.TaskRunners<object, System.Threading.Tasks.Task>.RunTask.AnonymousMethod__0(System.Threading.Tasks.Task t = Id = 4010, Status = RanToCompletion, Method = "{null}", Result = "") Line 1250
	at /_/src/Microsoft.AspNet.SignalR.Core/TaskAsyncHelper.cs(1250)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.TaskAsyncHelper.RunWithPreservedCulture.AnonymousMethod__71_0(System.Action<System.Threading.Tasks.Task> f = {Method = {System.Reflection.RuntimeMethodInfo}}, System.Threading.Tasks.Task state = Id = 4010, Status = RanToCompletion, Method = "{null}", Result = "") Line 1024
	at /_/src/Microsoft.AspNet.SignalR.Core/TaskAsyncHelper.cs(1024)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.TaskAsyncHelper.RunWithPreservedCulture<System.Action<System.Threading.Tasks.Task>, System.Threading.Tasks.Task, object>(Microsoft.AspNet.SignalR.TaskAsyncHelper.CulturePair preservedCulture = {Microsoft.AspNet.SignalR.TaskAsyncHelper.CulturePair}, System.Func<System.Action<System.Threading.Tasks.Task>, System.Threading.Tasks.Task, object> func = {Method = {System.Reflection.RuntimeMethodInfo}}, System.Action<System.Threading.Tasks.Task> arg1 = {Method = {System.Reflection.RuntimeMethodInfo}}, System.Threading.Tasks.Task arg2 = Id = 4010, Status = RanToCompletion, Method = "{null}", Result = "") Line 1006
	at /_/src/Microsoft.AspNet.SignalR.Core/TaskAsyncHelper.cs(1006)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.TaskAsyncHelper.RunWithPreservedCulture<System.Threading.Tasks.Task>(Microsoft.AspNet.SignalR.TaskAsyncHelper.CulturePair preservedCulture = {Microsoft.AspNet.SignalR.TaskAsyncHelper.CulturePair}, System.Action<System.Threading.Tasks.Task> action = {Method = {System.Reflection.RuntimeMethodInfo}}, System.Threading.Tasks.Task arg = Id = 4010, Status = RanToCompletion, Method = "{null}", Result = "") Line 1022
	at /_/src/Microsoft.AspNet.SignalR.Core/TaskAsyncHelper.cs(1022)
Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.TaskAsyncHelper.ContinueWithPreservedCulture.AnonymousMethod__0(System.Threading.Tasks.Task t = Id = 4010, Status = RanToCompletion, Method = "{null}", Result = "") Line 1044
	at /_/src/Microsoft.AspNet.SignalR.Core/TaskAsyncHelper.cs(1044)
mscorlib.dll!System.Threading.Tasks.Task.Execute()
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot = Id = 3992, Status = Running, Method = "Void <ContinueWithPreservedCulture>b__0(System.Threading.Tasks.Task)")
mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution)
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()
[Native to Managed Transition]

To Reproduce

I am unable to reproduce the issue with a new blank project; my project has IHttpModule classes of its own which may be implicated, but the fact this is an NRE with a symbol (requestTelementry == null) indicates a correctness issue within Microsoft.AI.Web regardless of my project set-up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions