Skip to content

System.Diagnostics.PerformanceCounter written perfcounters cannot be read on a machine without .NETFramework #46589

@ericstj

Description

@ericstj

Description

Related to #41144

With #45142 it is now possible to use this System.Diagnstics.PerformanceCounter on ARM64. It will function correctly for reading non-.NET perfcounters. .NET application provided perfcounters will still not work, but it will not fail: the instances will just not appear due to lack of the perfcounter.dll which exposes them to Windows.

Configuration

  • Which version of .NET is the code running on? -- .NET 5.0
  • What OS and version, and what distro if applicable? -- Windows 10
  • What is the architecture (x64, x86, ARM, ARM64)? -- ARM64
  • Do you know whether it is specific to that configuration? -- Yes

Regression?

No

Other information

If we wanted to fix this for System.Diagnstics.PerformanceCounter-provided performance counters we would need to port perfcounter.dll to ARM64 and carry this in the package. When registering a performance counter we would need to write the path to this local copy rather than the .NETFramework copy.

Workaround

Mentioned by @sywhang here: #41144 (comment)
It is recommended folks writing new counters use the EventCounters API instead of the System.Diagnostics.PerformanceCounter because it makes the counters cross-platform by default and makes it easier to integrate with the diagnostics pipeline we built around EventPipe in .NET Core. The runtime and several other parts of the stack (ASP.NET Core, BCL, EFCore, etc.) are already doing this, so it fits into the rest of the ecosystem better as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions