CsWinRT
CsWinRT copied to clipboard
CopyBuffer() method of SoftwareBitmap to an array crashes when trimming is enabled
Describe the bug
When using the CopyBuffer() method of a SoftwareBitmap to copy the pixels to a byte array the app crashes with an "Invalid cast" exception if trimming is enabled
To Reproduce
- Run attached repro project
Expected behavior
Should work the same as without trimming enabled
Version Info
WindowsAppSDK 1.2
Additional context
It seems that the issue is caused by the WindowsRuntimeBuffer class (and related extension methods like AsBuffer() for arrays) when trimming is enabled. Workaround: Add a TrimmerRootDescriptor file with the following content:
<linker>
<assembly fullname="Microsoft.Windows.SDK.NET">
<type fullname="System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBuffer"/>
</assembly>
</linker>