Unexpected error in .NET Core 3.1 when running "Collect metrics" sample from MS documentation
zsharp-gls opened this issue · 2 comments
Description
The "Collecting metrics" article on MS Learn lists that all of its steps should be compatible with .NET Core 3.1 or later. However, I get an Unsupported Command Exception
any time I target a .NET Core 3.1 app with dotnet-counters
.
My version of the sample in .NET Core 3.1 is available here
When I run the .NET Core 3.1 version, this is the output when I try to use dotnet-counters:
PS C:\Users\zsharp> dotnet-counters monitor -n metric-instr HatCo.HatStore
Unhandled exception: Microsoft.Diagnostics.NETCore.Client.UnsupportedCommandException: GetProcessInfo failed - Command is not supported.
at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.ValidateResponseMessage(IpcMessage responseMessage, String operationName, ValidateResponseOptions options) in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs:line 750
at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.GetProcessInfoFromResponse(IpcResponse response, String operationName) in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs:line 707
at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.GetProcessInfo() in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs:line 444
at Microsoft.Diagnostics.Tools.Counters.CounterMonitor.Monitor(CancellationToken ct, List`1 counter_list, String counters, IConsole console, Int32 processId, Int32 refreshInterval, String name, String diagnosticPort, Boolean resumeRuntime, Int32 maxHistograms, Int32 maxTimeSeries, TimeSpan duration, Boolean showDeltas) in /_/src/Tools/dotnet-counters/CounterMonitor.cs:line 213
at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__21_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__22_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__20_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()
I also created a branch targeting .NET 5.0, available here. When I run the same command against the .NET 5.0 version, it works just fine.
Configuration
System info
- Windows 11, version 23H2 (OS Build 22631.3155)
PS C:\Users\zsharp> dotnet --info
.NET SDK:
Version: 8.0.102
Commit: 64f1bc458e
Workload version: 8.0.100-manifests.bc6351c6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.102\
.NET workloads installed:
Workload version: 8.0.100-manifests.bc6351c6
There are no installed workloads to display.
dotnet-counter version
PS C:\Users\zsharp> dotnet tool list -g
Package Id Version Commands
--------------------------------------------------------------
dotnet-counters 8.0.510501 dotnet-counters
Other Info
I'm running this in a Windows PowerShell session with Administrator permissions. When I run without Administrator permissions, I get Unhandled exception: System.UnauthorizedAccessException: Access to the path is denied.
Hello @zsharp-gls, .NET Core 3.1 is no longer in support per https://devblogs.microsoft.com/dotnet/net-core-3-1-will-reach-end-of-support-on-december-13-2022/ and https://dotnet.microsoft.com/en-us/download/dotnet/3.1. Does this issue reproduce against a supported version of .NET? (e.g. .NET 6, .NET 7, .NET8)? I will change this to a documentation issue as we should remove references to unsupported .NET versions in our documentation.
Thanks for the explanation, @tommcdon. The issue doesn't reproduce even in .NET 5, so that lines up.
Would it be possible for the tool to detect when the target app is on an unsupported version of .NET and provide a warning? Even if I hadn't had the documentation I linked, nothing about the System.Diagnostics.DiagnosticSource
NuGet package or dotnet-counters
CLI made it obvious to me that I was going down an unsupported path.