Closed AnnaGorozia closed 2 years ago
We are seeing the same thing. I'd just add that it only occurs for us when we convert our application to use .Net 6. It works fine in .Net 5.
Hmm interesting. Going by the stack trace alone, it appears to be an issue with .NET 6 itself, not my code. Will try and reproduce myself.
I'm unable to reproduce- I suspect this is an issue with Visual Studio (although I cannot confirm this as I don't have a copy). When running in both the debug configuration and in Rider, the sample application didn't fail for me. Also, all the preexisting verbose GC event listener tests that target .net 6.0 are working as expected for me.
From memory, visual studio starts telemetry sessions when debugging to collect and display useful information (such as GCs)- I believe there is a conflict going on here.
As a workaround, for now I can suggest using Debugger.IsAttached
to detect when a debugger (such as VS) is detected- you can then not enable any verbose-level collection.
It wouldn't be appropriate to include this in the library as it seems that this is a VS-specific issue.
This is now fixed in .NET 7 and backported into next .NET 6 servicing release. 🥳
Thanks @sandersaares! Closing for now.
When we run our application locally in Debug mode, in runtime it throws NullReferenceException. It only happens when we configure DotNetRuntimeStats for GcsStats with CaptureLevel.Verbose. If we set CaptureLevel.Informational exception is not thrown.
I couldn't determine exact source of exception. Providing stack trace which I currently get:
I created sample app which shows similar behavior. You can check it out here: https://github.com/AnnaGorozia/PrometheusSample