shimat / opencvsharp_blazor_sample

OpenCvSharp + Blazor WebAssembly Code Samples
Apache License 2.0
12 stars 2 forks source link

.NET6 WebAssembly Error #4

Open sinisteralex opened 1 year ago

sinisteralex commented 1 year ago

Hello. I have started using this library to do some experiments with OpenCV and WebAssembly. The error underneath is a bit strange.

The code the error is pointing to is:

srcMat ??= Mat.FromImageData(imageBytes);

Error in browser:

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: The type initializer for 'OpenCvSharp.Internal.NativeMethods' threw an exception. System.TypeInitializationException: The type initializer for 'OpenCvSharp.Internal.NativeMethods' threw an exception. ---> OpenCvSharp.OpenCvSharpException: OpenCvSharpExtern ---> System.DllNotFoundException: OpenCvSharpExtern at OpenCvSharp.Internal.NativeMethods.TryPInvoke() --- End of inner exception stack trace --- at OpenCvSharp.Internal.NativeMethods.TryPInvoke() at OpenCvSharp.Internal.NativeMethods..cctor() --- End of inner exception stack trace --- at OpenCvSharp.Cv2.ImDecode(ReadOnlySpan`1 span, ImreadModes flags) at OpenCvSharp.Cv2.ImDecode(Byte[] buf, ImreadModes flags) at OpenCvSharp.Mat.ImDecode(Byte[] imageBytes, ImreadModes mode) at OpenCvSharp.Mat.FromImageData(Byte[] imageBytes, ImreadModes mode) at MudBlazorBlazor.Pages.OpenCV.OnAfterRenderAsync(Boolean firstRender) in D:\Repos\repos .NET\MudBlazorBlazor\MudBlazorBlazor\Pages\OpenCV.razor:line 53 at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)