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

ErrorHelper.GetErrorMessage throws System.OverflowException #467

Closed
pdupont1 opened this issue May 16, 2024 · 1 comment
Closed

ErrorHelper.GetErrorMessage throws System.OverflowException #467

pdupont1 opened this issue May 16, 2024 · 1 comment

Comments

@pdupont1
Copy link

Describe the bug and how to reproduce

HRESULT.ToString() throws System.OverflowException: Value was either too large or too small for a UInt32.

I tried updating our Project references Vanara.PInvoke.CldApi (3.4.17) and Vanara.PInvoke.SearchApi (3.4.17) to 4.0.1.
After updating the above mentioned exception is thrown when cloud API calls fail with a Win32 error code which was not the case before.

Stacktrace:

Convert.ThrowUInt32OverflowException()
IConvertible.ToUInt32(IFormatProvider provider)
ErrorHelper.GetErrorMessage[TType,TFieldType](TFieldType id, String lib)
HRESULT.ToString()

What code is involved

Vanara.PInvoke.Shared 4.0.1
.NET Runtime 8.0.5

Expected behavior

ToString() should succeed and return HRESULT_FROM_WIN32(ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT): The operation is only supported on files under a cloud sync root.

Repro is very simple by creating a HRESULT object from the error code returned by the Cloud API directly:

static void Main(string[] args)
{
    HRESULT hRESULT = HRESULT.HRESULT_FROM_WIN32(Win32Error.ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT);
    //Should print: HRESULT_FROM_WIN32(ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT): The operation is only supported on files under a cloud sync root.
    //Throws: HRESULT.ToString() throws `System.OverflowException: Value was either too large or too small for a UInt32.`
    Console.WriteLine("" + hRESULT);
    Console.Read();
}
@pdupont1 pdupont1 changed the title ErrorHelper.GetErrorMessage throws System.OverflowException: Value was either too large or too small for a UInt32. ErrorHelper.GetErrorMessage throws System.OverflowException May 16, 2024
@dahall dahall closed this as completed in 4b398b3 May 26, 2024
@dahall
Copy link
Owner

dahall commented May 26, 2024

I think this is fixed. I've tested your condition without failure with the pre-4.0.2 build. It should be available to test shortly from the AppVeyor feed (see homepage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants