Skip to content

RuntimeInformation.OSArchitecture returns X64 unexpectedly on arm64-Windows system #130398

Closed as not planned

Description

@JensNordenbro

Description

On Windows ARM (Surface Pro X) RuntimeInformation.OSArchitecture differs between net481 and net10.0 when RID win-x86 is forced.

Reproduction Steps

  1. Add this code to Program.cs on a Console app:
Architecture osArchitecture = RuntimeInformation.OSArchitecture;
Console.WriteLine($"OS Architecture: {osArchitecture}");
  1. compilie using dotnet publish -f net481 -r win-x86 ...

  2. Run executable

Expected behavior

"OS Architecture: Arm64" as console output, just like when publishing for framework net10.0 with the same rid.

Actual behavior

"OS Architecture: X64" as console output.

Regression?

Yes, we haad this working before but hard to reproduce.

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. added
    untriaged
    on Jul 9, 2026
  2. dotnet-policy-service commented on Jul 9, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-console
    See info in area-owners.md if you want to be subscribed.

  3. dotnet-policy-service commented on Jul 9, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/interop-contrib
    See info in area-owners.md if you want to be subscribed.

  4. huoyaoyuan commented on Jul 9, 2026

    @huoyaoyuan
    Member

    RID is not applicable to .NET Framework. .NET Framework produces AnyCPU exe and switches architecture via manifest configuration.

    The default for .NET Framework on ARM64 is always x64 emulation, which emulates a full x64 system. You can print ProcessArchitecture to confirm.

    To change the behavior, you can set following properties in csproj:

    • <PreferNativeArm64>true</PreferNativeArm64>

    ProcessArchitecture: ARM64 OSArchitecture: ARM64
    Process runs with native arm64.

    • <Prefer32Bit>true</Prefer32Bit>

    ProcessArchitecture: x86 OSArchitecture: ARM64
    Process runs with x86 emulation.

    • No option:

    ProcessArchitecture: x64 OSArchitecture: x64
    Process runs with x64 emulation.

  5. huoyaoyuan commented on Jul 9, 2026

    @huoyaoyuan
    Member

    The comment of .NET 10 also intentionally reports x64 OS for emulated x64:

    // If we are running an x64 process on a non-x64 windows machine, we will report x64 as OS architecture.

    Closing as by design.

  6. removed
    untriaged
    on Jul 9, 2026
  7. JensNordenbro commented on Jul 9, 2026

    @JensNordenbro
    Author

    Hmm...

    @huoyaoyuan , I dont think this exaplains it all.

    I get this scenario inside Windows Sandbox (on the host it works correctly) :

    Image

    This time I built using .NET Framework SDK more true to the scenario of our real world application that experiences problem.

    How is this explained?

  8. huoyaoyuan commented on Jul 9, 2026

    @huoyaoyuan
    Member

    I tested again and observed different behavior under different conditions:

    If launched via F5 under VS, it reports OS as x64:

    Image

    If launched via Ctrl+F5, or double clicking directly, it reports OS as ARM64:

    Image

    There may be more detail that I missed. This repo is not the best place to ask .NET Framework-specific questions. You can ask at Visual Studio Developer Community and the developers may answer you the behavior behind.

    Anyway, the ARM64 emulator tend to hide itself for processes that's non-native ARM64.

  9. JensNordenbro commented on Jul 9, 2026

    @JensNordenbro
    Author

    I would say, that this is a bug.
    Sandbox should not behave differently than host machine.

    Then again it might not be for this repo but notice that this behavior is true when .NET SDK is used to target net481 so...

  10. huoyaoyuan commented on Jul 9, 2026

    @huoyaoyuan
    Member

    SDK is totally unrelated to the behavior. It just sets corresponding flag/manifest and lets the runtime/OS to determine the behavior.

    Further issues should be reported to Developer Community.

  11. AaronRobinsonMSFT commented on Jul 9, 2026

    @AaronRobinsonMSFT
    Member

    Further issues should be reported to Developer Community.

    Correct. Since this issue is specifically about .NET Framework, regardless of how it is compiled, it should be reported at https://developercommunity.visualstudio.com/home.

  12. added
    tracking-external-issue
    on Jul 9, 2026
  13. MichalPetryka commented on Jul 10, 2026

    @MichalPetryka
    Contributor

    The comment of .NET 10 also intentionally reports x64 OS for emulated x64:

    runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Windows.cs

    Line 42 in 75fa507

    // If we are running an x64 process on a non-x64 windows machine, we will report x64 as OS architecture.
    Closing as by design.

    I would assume that to be a bug still, or the code was written before the API to detect that was added in build 22000.
    @jkotas Would it make sense to prefer GetProcessInformation with ProcessMachineTypeInfo there? AFAIR it's always accurate unlike IsWowProcess2.

  14. huoyaoyuan commented on Jul 10, 2026

    @huoyaoyuan
    Member

    The comment of .NET 10 also intentionally reports x64 OS for emulated x64:
    runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Windows.cs
    Line 42 in 75fa507
    // If we are running an x64 process on a non-x64 windows machine, we will report x64 as OS architecture.
    Closing as by design.

    I would assume that to be a bug still, or the code was written before the API to detect that was added in build 22000.

    The comment looks outdated. Tested on my Surface, x86 and x64 processes will both get OSArchitecture=ARM64 on .NET 10.

    Found the breaking change announcement for .NET 7:

    https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/7.0/osarchitecture-emulation

  15. MichalPetryka commented on Jul 10, 2026

    @MichalPetryka
    Contributor

    The comment of .NET 10 also intentionally reports x64 OS for emulated x64:
    runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Windows.cs
    Line 42 in 75fa507
    // If we are running an x64 process on a non-x64 windows machine, we will report x64 as OS architecture.
    Closing as by design.

    I would assume that to be a bug still, or the code was written before the API to detect that was added in build 22000.

    The comment looks outdated. Tested on my Surface, x86 and x64 processes will both get OSArchitecture=ARM64 on .NET 10.

    Found the breaking change announcement for .NET 7:

    https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/7.0/osarchitecture-emulation

    Ah wait I remembered incorrectly, it was the pProcessMachine that was wrong in IsWowProcess2, the pNativeMachine is correct.

  16. locked and limited conversation to collaborators on Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Runtime.InteropServicestracking-external-issue

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions