IvanJosipovic / BlazorApplicationInsights

Application Insights for Blazor web applications

Home Page:https://BlazorApplicationInsights.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NuGet Package 3.0.4 Application cannot start

stephajn opened this issue · comments

I upgraded from NuGet package 2.2.0 to 3.0.4 in a Blazor WASM project targeting .NET 8.

I followed the steps in the quick start.

  1. I updated my index.html file with the new JavaScript snippet
    image
  2. I updated my App.razor file, adding the new Init component at the very top of the file.
    image
  3. I updated my Program.cs file, changing the way I instantiated Application Insights
    image

This is the error I get in my console when the application tries to start. (Note the application never starts, and all I have is just the yellow bar of death)
image

I tried even adding a line in my csproj to exclude the assembly from being trimmed, although right now I'm not even having the assembly trimmed because I'm running in debug mode.
image

I also tried adding this to the top of my Program.cs just to make sure that the Config class didn't get trimmed out
image

That did change the error logged in my console, but the end result is still the same. The application will not start, and here's the new error in the browser console.
image

As soon as I rollback all of the changes and go back to version 2.2.0 of the NuGet package, everything works fine.

Updated to add that I also did this because the installation instructions no longer mention having to do it.
image

Same result.

Please help? :)

I'm unfortunately not able to reproduce this.

Can you try to reproduce the error with the sample project?

https://github.com/IvanJosipovic/BlazorApplicationInsights/tree/master/samples/BlazorApplicationInsights.Sample.Wasm

I had this exact issue when migrating from v2 to v3. Solved it by deleting the bin and obj folders.

Have you tried to use a connectionString instead of an instrumentationKey to see if it works any differently ? Try adding the connectionString statically first (before getting it from builder.Configuration). If possible, remove the extra elements you added such as commenting the script, the trimmer and DynamicallyAccessedMembers.

In other words, try to use only the steps you find here : https://github.com/IvanJosipovic/BlazorApplicationInsights?tab=readme-ov-file#install-on-blazor-webassembly-standalone-app