Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment.OSVersion returns "Windows NT 10.0.22458.0" on my Windows 11 22458.1000 #59427

Closed
mingtong opened this issue Sep 17, 2021 · 14 comments

Comments

@mingtong
Copy link

I am using .NET Framework 4.0.
Will the API return correct OS Version after Windows 11 released?
Sorry, I mean, what OS Version will be returned after Windows 11 released?

@joeloff
Copy link
Member

joeloff commented Sep 21, 2021

.NET 4 just like .NET only returns what we get from the OS. There are likely other APIs you can directly call using p/invoke. But I'll throw this over to runtime for better guidance. The repos here only deal with .NET Core and .NET 5, not .NET Framework

@joeloff joeloff transferred this issue from dotnet/sdk Sep 21, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Sep 21, 2021
@mingtong
Copy link
Author

.NET 4 just like .NET only returns what we get from the OS. There are likely other APIs you can directly call using p/invoke. But I'll throw this over to runtime for better guidance. The repos here only deal with .NET Core and .NET 5, not .NET Framework

Thanks for your reply.
I just tried .NET 6, it still returns the same.

@ghost
Copy link

ghost commented Sep 22, 2021

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

Issue Details

I am using .NET Framework 4.0.
Will the API return correct OS Version after Windows 11 released?
Sorry, I mean, what OS Version will be returned after Windows 11 released?

Author: mingtong
Assignees: -
Labels:

area-System.Runtime, untriaged

Milestone: -

@jeffschwMSFT
Copy link
Member

@danmoseley

@tannergooding
Copy link
Member

tannergooding commented Sep 22, 2021

This is simply the information reported by the OS.

Windows 11 is still 10.0.*.0 in the latest beta and (last I checked) internal preview builds:
image

You can confirm this by opening System Information.

@danmoseley
Copy link
Member

danmoseley commented Sep 22, 2021

This is correct -- we just pass the Windows version through.

Note that macOS is a bit more complicated as it depends on what SDK we built with, and we decided not to fake it (which means it can vary by .NET version)
#58575
#41012

cc @wfurt can confirm I stated this correctly.

@danmoseley
Copy link
Member

@mingtong for what purpose do you need to read the OS version? In theory logging/diagnostics is one of the few valid purposes. Generally it's not recommended to use the OS version to decide whether a feature is supported, because it might get supported later.

@mingtong
Copy link
Author

@mingtong for what purpose do you need to read the OS version? In theory logging/diagnostics is one of the few valid purposes. Generally it's not recommended to use the OS version to decide whether a feature is supported, because it might get supported later.

I pass the OS version to server, and server decide which data will be returned.

My App wants to support Windows 11 in advance, so I want to have it testable as early as possible, then once 11 be released, we can announce we support the latest Windows.

You said it's not recommended, then what is the best practice to do it?

@danmoseley
Copy link
Member

@mingtong I see. Could you share why the server needs to know the OS version of the client? What is the data and how does it change? If you lied and told the server you were running on a Windows 10 client, would it be a problem?

@wfurt
Copy link
Member

wfurt commented Sep 23, 2021

More discussion specific to Win11 is also here: #58588
#59135 makes detections based on build number. Since Windows 11 is really just newer Windows 10, is there specific functionality you are trying to detect @mingtong?

@mingtong
Copy link
Author

@mingtong I see. Could you share why the server needs to know the OS version of the client? What is the data and how does it change? If you lied and told the server you were running on a Windows 10 client, would it be a problem?

Some data is not expected to be shown on target OS.
If Windows 11 always return a version as Win 10, then it won't be a problem.
If Windows 11 returns a version as Win 11, then current code needs to be refactored.

@danmoseley
Copy link
Member

@mingtong but why is the version relevant -- why does the code need to be refactored? for what purpose is the version used?

If for example, you're checking whether a feature is supported, often there are more reliable ways to do this than checking a version number. Eg., GetProcAddress.

@jeffhandley jeffhandley added needs more info and removed untriaged New issue has not been triaged by the area owner labels Sep 30, 2021
@jeffhandley jeffhandley added this to the Future milestone Sep 30, 2021
@ghost ghost added the no-recent-activity label Nov 3, 2021
@ghost
Copy link

ghost commented Nov 3, 2021

This issue has been automatically marked no recent activity because it has been marked as needs more info but has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no recent activity.

Please refer to our contribution guidelines for tips on what information might be required.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2021
@eiriktsarpalis eiriktsarpalis added needs-author-action An issue or pull request that requires more info or actions from the author. and removed needs more info labels Jan 19, 2022
@ghost ghost removed the no-recent-activity label Jan 19, 2022
@tannergooding tannergooding removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants