dotnet / dotnet/dotnet-api-docs
Behavior of System.ComponentModel.Win32Exception.HResult does not match documentation
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
https://github.com/dotnet/runtime/issues/46829#issuecomment-761520732
# Description
(new System.ComponentModel.Win32Exception(0x50)).HResult.ToString("X") output 0x80004005. From the documentation of Exception.HResult: we get "The HRESULT value" and "Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception."
Spent some time debugging this before managing to reduce it to Win32Exception. The expected value this would have had from the documentation is 80070050 but it got 80004005. Either the documentation is wrong or the code is wrong. Bug has probably always existed. I can currently trace it as far back as existing in .NET Framework 4.0. Bug still exists in .NET 5.
# Configuration
All .NET Versions. All OSes.
# Regression?
No
# Other Information
It may or may not be a bug in .NET Core but it's not going to get fixed so the documentation should be updated. See linked issue.
Contributor guide
Assessment
This issue has not been assessed yet.