Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
GokulprasathVenkatachalam opened this issue Oct 15, 2024 · 3 comments · Fixed by #2620
Labels

Comments

@GokulprasathVenkatachalam

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
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@KameshRajendran
Copy link

I am also facing the same issue.

@GokulprasathVenkatachalam
Copy link
Author

Hi Team,

We have updated to the latest preview of 3.0.0-preview.5.3 in the early access NuGet feed and added the following codes in the .csproj file, which works fine with SkiaSharp access in Blazor WASM:

<PropertyGroup>
    <WasmNativeStrip>true</WasmNativeStrip>
    <WasmBuildNative>true</WasmBuildNative>
</PropertyGroup>

<ItemGroup>
    <NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.56\st\*.a" />
</ItemGroup>

I have attached a sample for your reference. When can we expect the standard release for these changes on nuget.org? Given that .NET 9 is scheduled for release on November 12, is it possible to have this release on or before that date?

Sample:
SkiaSharpNET9.zip

Thank you.

Best regards,
Gokulprasath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants