-
Notifications
You must be signed in to change notification settings - Fork 107
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
AoT: Failing to cast object to byte[] #1796
Comments
I was under the impression that arrays are illegal to use outside of parameters in the WinRT type system. https://learn.microsoft.com/en-us/uwp/winrt-cref/winrt-type-system#array-parameters |
@dongle-the-gadget are you saying we can't store any binary data (like data encrypted with the DataProtectionProvider) in the application settings? I mean it works fine - it's only in AoT mode it doesn't. .NET Native with UWP works fine also. |
It works but seems like undocumented behavior. The supported list of types in docs also doesn’t mention arrays. I suppose though that you can probably cast the object into an IPropertyValue and get the array from there. |
By any chance did you disable IReference support? |
Not that I know off? The code is in a net8.0-windows library. No explicit reference to WindowsAppSDK. |
This works via boxing support / |
Describe the bug
To Reproduce
Unable to cast object of type 'WinRT.IInspectable' to type 'System.Byte[]'.
Expected behavior
App settings gets the byte[].
Version Info
WinAppSDK 1.6.0, CSWinRT 2.1.3
Additional context
Also tried:
.As<byte[]>()
.As<IEnumerable<byte>>().ToArray()
Enumerable.Cast<byte[]>((IEnumerable)settings.Values["Test"])
The text was updated successfully, but these errors were encountered: