ApplicationInsights-dotnet icon indicating copy to clipboard operation
ApplicationInsights-dotnet copied to clipboard

System.TypeInitializationException: The type initializer for 'Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource' threw an exception

Open epananth opened this issue 4 years ago • 2 comments

  • List of NuGet packages and version that you are using: 2.16.0
  • Runtime version (e.g. net461, net48, netcoreapp2.1, netcoreapp3.1, etc. You can find this information from the *.csproj file): net472, netcoreapp3.1
  • Hosting environment (e.g. Azure Web App, App Service on Linux, Windows, Ubuntu, etc.): windows

Describe the bug

Introducing linux signing in Release pipeline, previously we used a separate pipeline to sign linux files-> https://dnceng.visualstudio.com/internal/_build?definitionId=555&_a=summary

I am trying to move this is to the release pipeline, I can sign the files successfully but after that I get this error


D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018: The "Microsoft.DotNet.SignTool.SignToolTask" task failed unexpectedly.
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018: System.TypeInitializationException: The type initializer for 'Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource' threw an exception.
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:  ---> System.NullReferenceException: Object reference not set to an instance of an object.
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Diagnostics.Tracing.CounterGroup.OnEventSourceCommand(Object sender, EventCommandEventArgs e)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Diagnostics.Tracing.EventSource.add_EventCommandExecuted(EventHandler`1 value)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Diagnostics.Tracing.CounterGroup.RegisterCommandCallback()
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Diagnostics.Tracing.CounterGroup..ctor(EventSource eventSource)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Diagnostics.Tracing.CounterGroup.GetCounterGroup(EventSource eventSource)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Diagnostics.Tracing.DiagnosticCounter.Publish()
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Diagnostics.Tracing.EventCounter..ctor(String name, EventSource eventSource)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..ctor()
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..cctor()
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    --- End of inner exception stack trace ---
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource.get_IsVerboseEnabled()
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Channel.InMemoryChannel.Send(ITelemetry item)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Extensibility.Implementation.TransmissionProcessor.Process(ITelemetry item)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryProcessorChain.Process(ITelemetry item)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Extensibility.TelemetrySink.Process(ITelemetry item)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Shared.Extensibility.Implementation.PassThroughProcessor.Process(ITelemetry item)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryProcessorChain.Process(ITelemetry item)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.TelemetryClient.Track(ITelemetry telemetry)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.TelemetryClient.TrackEvent(EventTelemetry telemetry)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.ApplicationInsights.TelemetryClient.TrackEvent(String eventName, IDictionary`2 properties, IDictionary`2 metrics)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.DotNet.SignTool.Telemetry.SendEvents() in /_/src/Microsoft.DotNet.SignTool/src/Telemetry.cs:line 40
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.DotNet.SignTool.SignToolTask.ExecuteImpl() in /_/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs:line 266
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.DotNet.SignTool.SignToolTask.Execute() in /_/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs:line 154
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018: --- End of stack trace from previous location ---
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
D:\workspace\_work\1\s\src\Microsoft.DotNet.Release\Microsoft.DotNet.Signing.Extensions\SignLinuxPackages.proj(52,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
##[error]Error: The process 'D:\workspace\_work\1\s\.dotnet\dotnet.exe' failed with exit code 1

Here is the link to one of the builds => https://dev.azure.com/dnceng/internal/_build/results?buildId=1205076&view=logs&j=d7f318d2-3658-5f56-29df-16b211ec56a6&t=7851342b-b7f6-561e-0dbe-e63708dfa83e

To Reproduce

Create a self-contained project using the template of your choice, apply the minimum required code to result in the issue you're observing.

We will close this issue if:

  • The repro project you share with us is complex. We can't investigate custom projects, so don't point us to such, please.
  • If we will not be able to repro the behavior you're reporting

For Immediate Support

For immediate support relating to the Application Insights .NET SDK we encourage you to file an Azure Support Request with Microsoft Azure instead of filing a GitHub Issue in this repository. You can do so by going online to the Azure portal and submitting a support request. Access to subscription management and billing support is included with your Microsoft Azure subscription, and technical support is provided through one of the Azure Support Plans. For step-by-step guidance for the Azure portal, see How to create an Azure support request. Alternatively, you can create and manage your support tickets programmatically using the Azure Support ticket REST API

epananth avatar Jul 06 '21 18:07 epananth

It's possible that this is https://github.com/microsoft/ApplicationInsights-dotnet/issues/2058, but it should be noted that the call stack @epananth reported is when running on Framework (net472). If it's confirmed that this is the same as issue 2058 (and will be fixed by that issue, then this issue could be tracked there instead.

chcosta avatar Jul 15 '21 23:07 chcosta

I'm seeing this same exception being thrown in GitHub codespaces when trying to load my project with Omnisharp. Fairly sure it's preventing syntax highlighting from working properly.

Full stack trace:

[info]: OmniSharp.MSBuild.ProjectManager
        Update project: StrixMusic.Wasm

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotImplementedException: The method or operation is not implemented.
  at System.Diagnostics.Tracing.EventSource.add_EventCommandExecuted (System.EventHandler`1[TEventArgs] value) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 
  at System.Diagnostics.Tracing.EventCounterGroup.RegisterCommandCallback () [0x0001e] in <256e03622bd74c54b056b7d84c71cceb>:0 
  at System.Diagnostics.Tracing.EventCounterGroup..ctor (System.Diagnostics.Tracing.EventSource eventSource) [0x00018] in <256e03622bd74c54b056b7d84c71cceb>:0 
  at System.Diagnostics.Tracing.EventCounterGroup.GetEventCounterGroup (System.Diagnostics.Tracing.EventSource eventSource) [0x00035] in <256e03622bd74c54b056b7d84c71cceb>:0 
  at System.Diagnostics.Tracing.EventCounter..ctor (System.String name, System.Diagnostics.Tracing.EventSource eventSource) [0x0002f] in <256e03622bd74c54b056b7d84c71cceb>:0 
  at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..ctor () [0x00011] in <d84a7fff20a34765bcd2f9e3266f56d7>:0 
  at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..cctor () [0x00000] in <d84a7fff20a34765bcd2f9e3266f56d7>:0 
   --- End of inner exception stack trace ---
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotImplementedException: The method or operation is not implemented.
  at System.Diagnostics.Tracing.EventSource.add_EventCommandExecuted (System.EventHandler`1[TEventArgs] value) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 
  at System.Diagnostics.Tracing.EventCounterGroup.RegisterCommandCallback () [0x0001e] in <256e03622bd74c54b056b7d84c71cceb>:0 
  at System.Diagnostics.Tracing.EventCounterGroup..ctor (System.Diagnostics.Tracing.EventSource eventSource) [0x00018] in <256e03622bd74c54b056b7d84c71cceb>:0 
  at System.Diagnostics.Tracing.EventCounterGroup.GetEventCounterGroup (System.Diagnostics.Tracing.EventSource eventSource) [0x00035] in <256e03622bd74c54b056b7d84c71cceb>:0 
  at System.Diagnostics.Tracing.EventCounter..ctor (System.String name, System.Diagnostics.Tracing.EventSource eventSource) [0x0002f] in <256e03622bd74c54b056b7d84c71cceb>:0 
  at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..ctor () [0x00011] in <d84a7fff20a34765bcd2f9e3266f56d7>:0 
  at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..cctor () [0x00000] in <d84a7fff20a34765bcd2f9e3266f56d7>:0 
   --- End of inner exception stack trace ---

Arlodotexe avatar Dec 23 '21 03:12 Arlodotexe

This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.

github-actions[bot] avatar Oct 20 '22 00:10 github-actions[bot]