dotnet / dotnet/dotnet-api-docs

Behavior of System.ComponentModel.Win32Exception.HResult does not match documentation

Open
#5,252 0 comments 0 reactions 0 assignees View on GitHub
area-System.ComponentModel Pri3 untriaged
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.