Skip to content

Unable to work with PerformanceCounters when running with Globalization Invariant Mode #65502

Closed

Description

@urikanonov

Description

PerformanceCounter's was creating culture objects using LCID. When running with Globalization Invariant Mode, it is not allowed to create any culture using LCID. Also, if the switch DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY is set to true there, it will not allow creating any culture even using culture names except the Invariant culture. That means PerformanceCounter library will not be usable at all when enabling the Globalization Invariant Mode.

The fix here is to allow running PerformanceCounter with the Globalization Invariant Mode and always report counters matching the English language at that time.

Reproduction Steps

Run an application in globalization invariant mode and create a PerformanceCounter.
See code in this PR fixing the issue for .NET 7:
https://github.com/dotnet/runtime/pull/65414/files#diff-b565316299a8eab77f34ea3c771ff19b01d91f26a278e935ccd7d5afcc11dd77

Expected behavior

To allow running PerformanceCounter with the Globalization Invariant Mode and always report counters matching the English language at that time.

Actual behavior

The CultureInfo ctor throws an exception.
The ask is the backport this fix to .NET 6:
https://github.com/dotnet/runtime/pull/65414/files#diff-b565316299a8eab77f34ea3c771ff19b01d91f26a278e935ccd7d5afcc11dd77

Regression?

No response

Known Workarounds

No response

Configuration

.NET 6, Windows

Other information

Need to backport the fix already checked in for .NET 7:
#65414

Activity

  1. ghost added
    untriaged
    on Feb 17, 2022
  2. added and removed
    untriaged
    on Feb 17, 2022
  3. self-assigned this
    on Feb 17, 2022
  4. modified the milestones: 6.0.x, 6.0.4 on Feb 17, 2022
  5. ghost added
    in-pr
    on Feb 18, 2022
  6. ghost removed
    in-pr
    on Mar 10, 2022
  7. tarekgh commented on Mar 10, 2022

    @tarekgh
    Member

    The PR #65537 fixed this.

  8. ghost locked as resolved and limited conversation to collaborators on Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions