Skip to content

[BUG] System.DllNotFoundException: libSkiaSharp when using SkiaSharp.Blazor.Views in Blazor WASM in .NET 9 RC2 #3037

@GokulprasathVenkatachalam

Description

Description

I created a new WASM project using SkiaSharp.Blazor.Views to utilize SKPath, but it throws an exception, preventing access to the SkiaSharp object.

My project references the following package:

      <PackageReference Include="SkiaSharp.Views.Blazor" Version="2.88.8" />

.NET 8:

default.NET8.mp4

.NET 8 Sample:
SkiaSharpNET8.zip

.NET 9:

default.NET9.mp4

.NET 9 Sample:
SkiaSharpNET9.zip

This issue only occurs in .NET 9; it worked perfectly in .NET 8. Could you please investigate this issue and provide suggestions?

Code

Code Snippet:
Home.razor

@page "/"
@using SkiaSharp;

<div>SkiaSharp NET 9</div>
@code {
    SKPath DrawingPath = new SKPath();
}

.NET9 Sample:
SkiaSharpNET9.zip

Expected Behavior

Ensure the sample runs without exceptions, similar to how it worked in .NET 8.

Actual Behavior

It throws a System.DllNotFoundException: libSkiaSharp exception.
image

Version of SkiaSharp

2.88.8 (Current)

Last Known Good Version of SkiaSharp

2.88.6 (Deprecated)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Windows 11

Devices

No response

Relevant Screenshots

image

Relevant Log Output

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: libSkiaSharp
System.DllNotFoundException: libSkiaSharp
   at SkiaSharp.SKPath..ctor()
   at SkiaSharpNET9.Pages.Home..ctor() in D:\Net9\SkiaSharpNET9\SkiaSharpNET9\Pages\Home.razor:line 6
   at System.Object.InvokeStub_Home..ctor(Object , Object , Object , Object , Object )
   at System.Reflection.ConstructorInvoker.InvokeImpl(Object arg1, Object arg2, Object arg3, Object arg4)
   at System.Reflection.ConstructorInvoker.Invoke()
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.<>c__DisplayClass17_0.<CreateFactoryReflection>b__0(IServiceProvider serviceProvider, Object[] arguments)
   at Microsoft.AspNetCore.Components.DefaultComponentActivator.CreateInstance(Type componentType)
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Error: No element is currently associated with component 6
Error: No element is currently associated with component 6

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions