Bug Report: `CreateBitmapFromMemory` Exception in LINQPad 8 with Vortice.Direct2D1 Version 3.6.2
Description
NOTE: this bug is transfer from: https://github.com/amerkoleci/Vortice.Windows/issues/474
I encountered an issue when running a LINQPad 8 script using Vortice.Direct2D1
version 3.6.2. The CreateBitmapFromMemory
method throws an exception for this particular version, although the same code works without issues in Visual Studio 2022 and with version 3.5.0 of Vortice.Direct2D1
.
Exception Details
Message: The type initializer for '<Module>' threw an exception. InnerException: MissingMethodException: Method not found: 'Void WinRT.ComWrappersSupport.RegisterTypeComInterfaceEntriesLookup(System.Func`2<System.Type,ComInterfaceEntry[]>)'. StackTrace: at Vortice.WIC.PixelFormat..cctor() at UserQuery.Main(), line 6 Data: (0 items) HelpLink: null HResult: -2146233036 Source: Vortice.Direct2D1 TargetSite: System.Reflection.MethodBase TypeName: <Module>
Steps to Reproduce
- Open LINQPad 8.
- Set the query kind to "Statements".
- Add the NuGet reference for version 3.6.2 of Vortice.Direct2D1.
Use the following code to attempt to create a bitmap:
<Query Kind="Statements"> <NuGetReference>Vortice.Direct2D1</NuGetReference> <Namespace>Vortice.Direct2D1</Namespace> <Namespace>Vortice.WIC</Namespace> </Query> using IWICImagingFactory2 wic = new(); using ID2D1Factory d2dFac = D2D1.D2D1CreateFactory<ID2D1Factory>(); var data = new byte[640 * 480 * 4]; fixed (byte* ptr = data) { using IWICBitmap bmp = wic.CreateBitmapFromMemory(640, 480, PixelFormat.Format32bppPBGRA, (nint)ptr); }
Run the query and observe the exception.
Expected Behavior
The script should execute successfully, as it does using Visual Studio 2022 and with Vortice.Direct2D1
version 3.5.0, without throwing any exceptions.
Actual Behavior
The execution in LINQPad 8 throws a MissingMethodException
when using Vortice.Direct2D1
version 3.6.2.
Environment
- Operating System: Windows 11
- .NET Core/Framework Version: .NET 9
- LINQPad Version: 8
- Vortice.Direct2D1 Version: 3.6.2
Additional Information
The issue seems to be isolated to LINQPad 8, as no issues occur when the same code is run in a Console application within Visual Studio 2022. I have confirmed that all dependencies are correctly updated, ruling out the possibility of mismatched Vortice versions. Version 3.5.0 of Vortice.Direct2D1
functions correctly in LINQPad 8.
I would appreciate any insights or guidance on addressing this issue within the context of LINQPad 8. Thank you for your assistance.
Comments
Does it help if you add a NuGet package reference to Microsoft.Windows.SDK.NET.ref?
Yes I confirmed after I installed Microsoft.Windows.SDK.NET.ref then the code works.
And also confirmed after upgrade into LINQPad 8.7.4, code also works without install that
Microsoft.Windows.SDK.NET.ref
nuget package, thanks!Ha! I had a hunch as to what would fix it.
Could you update github issue please?
Done.