Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

2.7.1 and 2.8.0-beta1 throws NullReferenceException when used together with AspNetCore 3.0 preview8 #957

Closed
ronnygunawan opened this issue Aug 14, 2019 · 6 comments
Labels
Milestone

Comments

@ronnygunawan
Copy link

ronnygunawan commented Aug 14, 2019

Repro Steps

  1. Create new ASP.NET Core Web Application (Model-View-Controller) using .NET Core 3.0.0-preview8-013656
  2. Add NuGet package: Microsoft.ApplicationInsights.AspNetCore 2.7.1 or 2.8.0-beta1
  3. Add following line to ConfigureServices method in Startup.cs:
    services.AddApplicationInsightsTelemetry();
  4. Start debugging

Actual Behavior

Home page displays error:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners.Implementation.PropertyFetcher.Fetch(Object obj)
   at Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners.HostingDiagnosticListener.OnNext(KeyValuePair`2 value)
   at System.Diagnostics.DiagnosticListener.Write(String name, Object value)
   at Microsoft.AspNetCore.Mvc.MvcCoreDiagnosticListenerExtensions.BeforeActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.SetRoutingAndContinue(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Expected Behavior

Normal home page

Version Info

SDK Version: 2.7.1 or 2.8.0-beta1
.NET Core Version: 3.0.0-preview8-013656
How Application was onboarded with SDK: Visual Studio Community 2019 Preview Version 16.3.0 Preview 2.0, Installed NuGets: Microsoft.ApplicationInsights.AspNetCore 2.8.0-beta1
OS: Windows 10 Version 1903
Hosting Info: Running From Visual Studio

@lmolkova
Copy link
Member

Thanks for reporting it and providing stack trace. This is most likely the same as #936 - we'll address it in the next stable release (early October) and we'll do our best to include the fix in the next beta

@lmolkova lmolkova added bug p1 high priority labels Aug 14, 2019
@lmolkova lmolkova added this to the 2.8.0 milestone Aug 14, 2019
@cijothomas
Copy link
Contributor

Even if sdk does not quite well support 3.0, it should not have crashed/errored user app under any circumstances.
The listener code was wrapper in try..catch to catch all these potential unknowns in the following PR.
https://github.com/microsoft/ApplicationInsights-aspnetcore/pull/869/files#diff-127c7a3a6227c377b206b4904744707c

However, the above was accidentally overwritten in the perf fixes PR :(
https://github.com/microsoft/ApplicationInsights-aspnetcore/pull/907/files#diff-127c7a3a6227c377b206b4904744707c

  1. Need to ensure all code is try.catch ed. (P1)
  2. Actual fix for 3.0 listener changes

@magnuskarlssonhm
Copy link

Is there a workaround for this? I'm setting up a new project with aspnet core preview8.

@cijothomas
Copy link
Contributor

@magnuskarlssonhm No workaround unfortunately. This is being fixed in https://github.com/microsoft/ApplicationInsights-aspnetcore/pull/959/files. It will be part of next beta.

@cijothomas
Copy link
Contributor

@magnuskarlssonhm sdk with fix for this issue is released now.
https://github.com/microsoft/ApplicationInsights-aspnetcore/releases/tag/2.8.0-beta2
(https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore/2.8.0-beta2)

@magnuskarlssonhm
Copy link

@cijothomas Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants