Canvas icon indicating copy to clipboard operation
Canvas copied to clipboard

Could not find 'BlazorExtensions.Canvas2d.add' ('BlazorExtensions' was undefined)

Open DerekR15 opened this issue 4 years ago • 5 comments

I followed the steps in the ReadMe to create a 2D canvas component. However, when I run my application on localhost using IIS, I get the following error in the console:

Could not find 'BlazorExtensions.Canvas2d.add' ('BlazorExtensions' was undefined)

I've added usings everywhere I'm supposed to, and Googling this issue turned up just about nothing, so I'm not sure what else to try. Any help would be appreciated.

DerekR15 avatar Jul 24 '21 19:07 DerekR15

Sorry to be late to the party. I ran into this same issue. The fix was to add this to my index.html. Hope it helps.

<script src="_content/Blazor.Extensions.Canvas/blazor.extensions.canvas.js"></script>

pdavis68 avatar Dec 15 '21 16:12 pdavis68

Even it you do add the script to a client's project's index.html it only seems to work properly if the server project also has the Blazor.Extensions.Canvas installed.

If not, drawing will result in faults until the browser is refreshed.

wvdvegt avatar Jan 04 '23 09:01 wvdvegt

Fixed it for me, thanks !

MowedMeadow avatar Jan 17 '23 20:01 MowedMeadow

~~Hey I'm also getting this error. I already have~~ ~~<script src="_content/Blazor.Extensions.Canvas/blazor.extensions.canvas.js"></script>~~ ~~In my index.html though. And added following to my _Imports.razor~~ ~~@using Blazor.Extensions @using Blazor.Extensions.Canvas @using Blazor.Extensions.Canvas.Canvas2D~~

~~The only thing I'm doing in the canvas is using DrawImageAsync in order to add an image.~~

I retried thing about 100 times and rebuilding and it didn't work. I'd given up but after few days came back and it was just working. So clearly something was just stale.

mwsaari avatar Jun 11 '23 21:06 mwsaari