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

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

Open
aschilr opened this issue Apr 20, 2024 · 2 comments

Comments

@aschilr
Copy link

aschilr commented Apr 20, 2024

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)

@AmenallahBarkaoui
Copy link

AmenallahBarkaoui commented May 29, 2024

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:
<script src="_content/BlazorBarcodeScanner.ZXing.JS/zxingjs.index.min.js"></script>
<script src="_content/BlazorBarcodeScanner.ZXing.JS/BlazorBarcodeScanner.js"></script>

@michielvh2002
Copy link

michielvh2002 commented Aug 12, 2024

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)

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

No branches or pull requests

3 participants