BlazorBarcodeScanner icon indicating copy to clipboard operation
BlazorBarcodeScanner copied to clipboard

New Blazor Wasm project .net8 throws Could not find 'Helpers.setDotNetHelper'

Open aschilr opened this issue 1 year ago • 2 comments

I created a new .net8 Blazor Wasm project and inserted only Blazor Barcode Scanner as described. Inserted the component in the Home.razor and got the following error:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Could not find 'Helpers.setDotNetHelper' ('Helpers' was undefined). Error: Could not find 'Helpers.setDotNetHelper' ('Helpers' was undefined). at https://localhost:7083/_framework/blazor.web.js:1:734 at Array.forEach () at l.findFunction (https://localhost:7083/_framework/blazor.web.js:1:702) at b (https://localhost:7083/_framework/blazor.web.js:1:5445) at https://localhost:7083/_framework/blazor.web.js:1:3238 at new Promise () at y.beginInvokeJSFromDotNet (https://localhost:7083/_framework/blazor.web.js:1:3201) at Object.ri [as invokeJSJson] (https://localhost:7083/_framework/blazor.web.js:1:165152) at https://localhost:7083/_framework/dotnet.runtime.8.0.3.lxiirgj8ch.js:3:178111 at xl (https://localhost:7083/_framework/dotnet.runtime.8.0.3.lxiirgj8ch.js:3:178945)

aschilr avatar Apr 20 '24 07:04 aschilr

I think you just need to add the following lines to wwwroot\index.html (for server side _Host.cshtml) before the closing body tag as mentioned in the doc:

AmenallahBarkaoui avatar May 29 '24 09:05 AmenallahBarkaoui

I have the same problem and I added those lines. I will come back if I find the cause.

Update: you also have to install the package in the server and add the script tags to your _Host.cshtml file, not your index.html in the client. This is poorly explained in the docs. (Yes this is for WASM, not server side or combined)

michielvh2002 avatar Aug 12 '24 11:08 michielvh2002