Resolving Managed Vtable Types NotSupportedException with Telerik .NET MAUI SkiaSharp controls on Windows
Environment
Product | DataGrid, BusyIndicator, Gauge and other Telerik controls rendered through SkiaSharp |
Description
This article describes how to resolve the following error on Windows:
System.NotSupportedException: Managed vtable types (ie. containing any reference types) are not supported.
This exception occurs when:
- You are using any of the Telerik .NET MAUI SkiaSharp controls, such as DataGrid, BusyIndicator, Gauge; and
- you've updated Visual Studio 2022 to Version 17.11.5; or
- you're using the CommunityToolkit and have explicitly set the Windows SDK version in the .csproj file due to its requirement, such as:
<WindowsSdkPackageVersion>10.0.19041.41</WindowsSdkPackageVersion>
Cause
The exception is related to a known issue in the SkiaSharp library with WindowsSdkPackageVersion
10.0.19041.38 and above:
https://github.com/mono/SkiaSharp/issues/2999
Solution
To resolve this issue, update the .NET Windows SDK version in your project. Modify the project file (.csproj) to include the following line, which specifies a version of the Windows SDK where the issue has been fixed:
<WindowsSdkPackageVersion>10.0.19041.54</WindowsSdkPackageVersion>
By adding this line to your project file, you ensure that your application uses a version of the Windows SDK that includes the necessary fix for the NotSupportedException
related to managed vtable types.