How to use .NET Platform Extension 6 in Visual Studio 2022 project?

Nicholas Piazza 541 Reputation points
2022-01-02T20:12:19.02+00:00

I am trying to create a Console application project in Visual Studio 2022 that runs the example in the .NET Platform Extensions 6 version of System.Diagnostics (https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.countercreationdata?view=dotnet-plat-ext-6.0#examples). When I add the line

private static PerformanceCounter avgCounter64Sample;

to the application, the type PerformanceCounter shows up as not found. If I add "using System.Diagnostics;" it has the same problem, because it references the .NET 6 version of System.Diagnostics, which does not have a definition for PerformanceCounter. It needs to reference the .NET Platform Extensions 6 version of System.Diagnostics. How do I configure a project file to reference that version? And, in general, how do I reference other files in the .NET Platform Extensions 6 area?

Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 78,086 Reputation points Volunteer Moderator
    2022-01-02T20:45:43.447+00:00

    you need to install the windows compatibility pack as these are windows only extensions

    https://www.nuget.org/packages/Microsoft.Windows.Compatibility

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.