iso8859 / BlazorWheelZoom

Zoom and move image with Blazor - minimal javascript
Apache License 2.0
13 stars 2 forks source link

Blazor server crashes when setting base64 image #1

Closed MarvinKlein1508 closed 3 years ago

MarvinKlein1508 commented 3 years ago

I want to use this library within a blazor server application. However, I don't have the images as image file. I only have them as base64 string.

When I try to display such string, my application crashes and gives me the following error message:

[2021-03-18T16:39:06.287Z] Error: Microsoft.JSInterop.JSException: Could not find 'WheelZoomJsFunctions.boundingRect' ('WheelZoomJsFunctions' was undefined). r</e.prototype.findFunction/<@https://localhost:5001/_framework/blazor.server.js:1:67390 r</e.prototype.findFunction@https://localhost:5001/_framework/blazor.server.js:1:67350 v@https://localhost:5001/_framework/blazor.server.js:1:69092 beginInvokeJSFromDotNet/i<@https://localhost:5001/_framework/blazor.server.js:1:70038 beginInvokeJSFromDotNet@https://localhost:5001/_framework/blazor.server.js:1:70011 O</e.prototype.invokeClientMethod/<@https://localhost:5001/_framework/blazor.server.js:1:26293 O</e.prototype.invokeClientMethod@https://localhost:5001/_framework/blazor.server.js:1:26263 O</e.prototype.processIncomingData@https://localhost:5001/_framework/blazor.server.js:1:24201 e/this.connection.onreceive@https://localhost:5001/_framework/blazor.server.js:1:17286 J</e.prototype.connect/</</</i.onmessage@https://localhost:5001/_framework/blazor.server.js:1:46503

at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)

at BlazorWheelZoomLibrary.Shared.WheelZoom.InitAsync()

at BlazorWheelZoomLibrary.Shared.WheelZoom.OnAfterRenderAsync(Boolean firstRender)

at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

I implemented your component as: <WheelZoom Image="@($"data:image/png;base64, {image}")" width="583" height="820" />

iso8859 commented 3 years ago

Hi, This error is not related to base64 image. You forgot to add

in _Host.cshtml

Anyway without this missing line it was not working. I fixed it, please upate and look at this example Index.razor

MarvinKlein1508 commented 3 years ago

@iso8859 I had this code in my _Host.cshtml. I did everything as you described in your READ.ME

I will check out the update later today and let you know if it works or not.

MarvinKlein1508 commented 3 years ago

@iso8859 with the updated library it works fine for me. However, you forgot to publish the update to nuget.

iso8859 commented 3 years ago

@MarvinKlein1508 I forget. Update published.