Marshalling Error for WinUI 3 Application

Hemanth B 886 Reputation points
2025-02-06T17:52:05.8566667+00:00

Hello. So I've been creating a WinUI 3 app C# in visual studio. For loading the list of installed fonts, I had to install Microsoft.Graphics.Win2D NuGet package. For that, it required me to update the NuGet packages of "WindowsAppSDK" and "Windows.SDK.BuildTools" to the latest versions. I've attached the list of packages I've installed/updated below. The Win2D package gets installed successfully but there is an error saying "This version of the Windows App SDK requires Microsoft.Windows.SDK.NET.Ref 10.0.19041.38 or later". So, when I searched this error in Google, some people said to use this in the project file,

<WindowsSdkPackageVersion>10.0.19041.41</WindowsSdkPackageVersion> 

I've used that but following up another error pops up saying "Cannot find type System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider in module System.Runtime.InteropServices.dll.". I've searched up this error but no results. I have no clue about this. Please help me out. Thank you.

User's image

User's image

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
821 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,279 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,664 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.