Hello fellow developers,
I hope you're all doing well. I'm currently working on a .NET MAUI project and I'm facing some issues with integrating SkiaSharp into my application. I've followed the usual steps, but my app is getting stuck with an unhandled exception in the WinUI layer.
Here's what I've done so far:
- Created a new .NET MAUI app.
- Added the SkiaSharp.Views.Maui.Controls and SkiaSharp.Views.Maui.Core libraries.
- Set up the XAML layout with a SKCanvasView.
- Added a PaintSurface event handler.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:skia="clr-namespace:SkiaSharp.Views.Maui.Controls;assembly=SkiaSharp.Views.Maui.Controls"
x:Class="MauiApp5.MainPage">
<StackLayout>
<skia:SKCanvasView
x:Name="skiaView"
PaintSurface="OnPaintSurface"/>
</StackLayout>
</ContentPage>
namespace MauiApp5
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnPaintSurface(object sender, SkiaSharp.Views.Maui.SKPaintSurfaceEventArgs e)
{
}
}
}
However, when I run the app, it crashes with the following message:
MauiApp5.dll!MauiApp5.WinUI.App.InitializeComponent.AnonymousMethod__3_1(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) Line 68 C#
I've checked my SkiaSharp version, ensured the environment is set up correctly, and double-checked my code for any errors. Still, I can't figure out what's causing the issue.
Has anyone encountered a similar problem or could provide guidance on what might be going wrong? Any help or insights would be greatly appreciated.
Thank you in advance!