none
System.Environment.OSVersion - returns incorrect version for Win 8.1 RRS feed

  • Question

  • When I use
    "System.Environment.OSVersion" from .net code. I get Windows version
    6.2.9200 (not correct version)

    When I use PowerShell with

    [System.Environment]::OSVersion.Version
    I get 6.3.9600 (This is the correct version) I have Windows 8.1

    Is this a .net bug?


    Tuesday, May 10, 2016 10:54 PM

Answers

All replies

  • Nope. The underline Win32 API now turn on the version cheating compatibility shim by default. 

    If you want to detect Windows 8.1 you now have to declare support for Windows 8.1 in your manifest first



    Visual C++ MVP

    • Proposed as answer by Kristin Xie Friday, May 20, 2016 9:39 AM
    Wednesday, May 11, 2016 12:58 AM
  • Hi Bret,

    It's not a bug, it's in MSDN:

    Operating system Version number
    Windows 10 10.0*
    Windows Server 2016 Technical Preview 10.0*
    Windows 8.1 6.3*
    For more details, please refer to https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx

                                              

    For applications that have been manifested for Windows 8.1 or Windows 10 Insider Preview. Applications not manifested for Windows 8.1 or Windows 10 Insider Preview will return the Windows 8 OS version value (6.2).  Read the MSDN page, especially the Targeting your application for Windows link.

    Have a nice day!

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Kristin Xie Wednesday, May 11, 2016 5:37 AM
    • Proposed as answer by Kristin Xie Friday, May 20, 2016 9:39 AM
    Wednesday, May 11, 2016 5:37 AM
  • Thanks for the information was helpful

    Any chance there are samples on adding the manifest to a C# Windows Application. I have added the app.manifest file but still getting 6.2 for version from System.Environment.OSVersion

    Bret

    Wednesday, May 11, 2016 2:41 PM
  • application manifest file is one of the item templates you can add to your project in solution explorer.


    Visual C++ MVP

    • Marked as answer by Bret Pelkey Friday, May 20, 2016 4:11 PM
    Wednesday, May 11, 2016 3:47 PM