Blazor.Cropper icon indicating copy to clipboard operation
Blazor.Cropper copied to clipboard

MissingMethodException: Method not found: 'SixLabors.ImageSharp.Formats.IImageFormat on Cropper.LoadImage()

Open brauerj-gc opened this issue 1 year ago • 7 comments

With any ABP.IO Blazor Server project using version 7.0 (dotnet and ABP) I get the following error! I'm seem to be unable to fix it.

Error: System.MissingMethodException: Method not found: 'SixLabors.ImageSharp.Formats.IImageFormat SixLabors.ImageSharp.Formats.ImageFormatManager.FindFormatByFileExtension(System.String)'. at Blazor.Cropper.Cropper.LoadImage(String ext, IBrowserFile resizedImageFile) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Blazor.Cropper.Cropper.LoadImage(String ext, IBrowserFile resizedImageFile) at Blazor.Cropper.Cropper.OnParametersSetAsync() in C:\Users\brauerj\source\repos\MyReport7\dependencies\Blazor.Cropper\Blazor.Cropper\Cropper.razor.cs:line 376 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Any suggestions?

brauerj-gc avatar Mar 15 '23 18:03 brauerj-gc

Here is a repository showing a working 7.0 and broken ABP 7.0 example: https://github.com/brauerj-gc/CropperError-ABP7-and-dotnet7 (browse to /cropper after loading either Blazor app)

brauerj-gc avatar Mar 16 '23 00:03 brauerj-gc

Hi @brauerj-gc , thanks for reporting this issue. This seems like a bug in dotnet runtime (https://github.com/dotnet/aspnetcore/issues/40033), could you try the workaround described there?

Unfortunately, I am currently tied up with other obligations and am unable to investigate the sample project at this moment. I apologize for any inconvenience that this may cause.

Please feel free to reach out if you have any further questions or concerns.

Chronostasys avatar Mar 17 '23 12:03 Chronostasys

I don't believe I am using trimming so not sure how it is related to that bug... I may try to dig in deeper here in a few weeks. I understand being otherwise engaged...

brauerj-gc avatar Mar 20 '23 15:03 brauerj-gc

I'm running into the same issue even though I'm not using ABP.IO. Was working a couple days ago and it started throwing after the setting the image OnInputFileChange

:Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Method not found: SixLabors.ImageSharp.Image SixLabors.ImageSharp.Image.Load(byte[],SixLabors.ImageSharp.Formats.IImageFormat&) System.MissingMethodException: Method not found: SixLabors.ImageSharp.Image SixLabors.ImageSharp.Image.Load(byte[],SixLabors.ImageSharp.Formats.IImageFormat&) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[<LoadImage>d__176](<LoadImage>d__176& ) at Blazor.Cropper.Cropper.LoadImage(String ext, IBrowserFile resizedImageFile) at Blazor.Cropper.Cropper.OnParametersSetAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task , ComponentState )

saascentral avatar Mar 28 '23 02:03 saascentral

Not sure if it's related to @brauerj-gc 's issue but I found out the cause of my issue with the Method Not Found error. I had another package that updated SixLabors.ImageSharp to 3.0 which caused Cropper to break. Downgrading SixLabors.ImageSharp to 2.1.3 seems to resolved my issue.

saascentral avatar Mar 28 '23 02:03 saascentral

Downgrading SixLabors.ImageSharp to 2.1.3 solved my error but now the image itself is never set in the cropper and there seems to be an "Object reference not set to an instance of an object" error on this line: var args = await cropper.GetCropedResult();

In the logs I see:

2023-03-28 10:19:36.708 -04:00 [ERR] Unhandled exception in circuit '3uPJOeuzhIWTEjqfcZDpFbwwvsGH_TaDHiSgKPjAE78'. System.TimeoutException: Did not receive any data in the allotted time. at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at System.IO.Pipelines.PipeReaderStream.ReadAsyncInternal(Memory`1 buffer, CancellationToken cancellationToken)

and

2023-03-28 10:19:36.742 -04:00 [INF] Connection id "0HMPFIT2ID533", Request id "0HMPFIT2ID533:0000009B": the application completed without reading the entire request body. 2023-03-28 10:19:36.758 -04:00 [WRN] Unhandled exception rendering component: Did not receive any data in the allotted time. System.TimeoutException: Did not receive any data in the allotted time. at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at System.IO.Pipelines.PipeReaderStream.ReadAsyncInternal(Memory1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSDataStream.ReadAsync(Memory1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.Components.Forms.BrowserFileStream.CopyFileDataIntoBuffer(Memory1 destination, CancellationToken cancellationToken) at Microsoft.AspNetCore.Components.Forms.BrowserFileStream.ReadAsync(Memory1 buffer, CancellationToken cancellationToken) at System.IO.Stream.<CopyToAsync>g__Core|27_0(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken) at System.Net.Http.StreamToStreamCopy.<CopyAsync>g__DisposeSourceAsync|1_0(Task copyTask, Stream source) at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer) at System.Net.Http.HttpContent.WaitAndReturnAsync[TState,TResult](Task waitTask, TState state, Func`2 returnFunc) at Blazor.Cropper.Cropper.LoadImage(String ext, IBrowserFile resizedImageFile) at Blazor.Cropper.Cropper.OnParametersSetAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

brauerj-gc avatar Mar 28 '23 14:03 brauerj-gc

This workaround (what little it did) seems to completely not work as of .net 8. Using Client/Server/Shared model, and no matter the version of SixLabors.ImageSharp, even though it is loaded as a wasm module, it still fails with Method not found image image

GMatrixGames avatar Feb 05 '24 04:02 GMatrixGames