Skip to content

InvalidOperationException from Microsoft.ApplicationInsights 3.1.0 Packages in ASP.Net 4.8 #3163

Description

@timomta

Microsoft.ApplicationInsights 3.1.0
Microsoft.ApplicationInsights.Web 3.1.0

  • Runtime version (e.g. net461, net48, netcoreapp2.1, netcoreapp3.1, etc. You can find this information from the *.csproj file):

net48

  • Hosting environment (e.g. Azure Web App, App Service on Linux, Windows, Ubuntu, etc.):

Windows Azure Web App

Describe the bug

I included the above packages in an ASP.Net 4.8 application
Followed the guidance here, using the option to set APPLICATIONINSIGHTS_CONNECTION_STRING in the web app configuration: https://github.com/microsoft/ApplicationInsights-dotnet/blob/main/MigrationGuidance.md#microsoftapplicationinsightsweb

The application now throws the following exception at startup:
Server Error in '/' Application.
Configuration cannot be modified after it has been built. Create a new TelemetryConfiguration instance if you need different settings.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Configuration cannot be modified after it has been built. Create a new TelemetryConfiguration instance if you need different settings.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: Configuration cannot be modified after it has been built. Create a new TelemetryConfiguration instance if you need different settings.]
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.ThrowIfBuilt() in //BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs:505
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.PrependOpenTelemetryBuilderConfiguration(Action`1 configure) in /
/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs:325
Microsoft.ApplicationInsights.TelemetryClient..ctor(TelemetryConfiguration configuration, Boolean isFromDependencyInjection) in //BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs:71
Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule.OnBeginRequest(Object sender, EventArgs eventArgs) in /
/WEB/Src/Web/Web/ApplicationInsightsHttpModule.cs:242
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +218
System.Web.<>c__DisplayClass285_0.b__0() +36
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +121
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.9318.0

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions