This is a migrated thread and some comments may be shown as answers.
Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
6 Answers 122 Views
This is a migrated thread and some comments may be shown as answers.
Wayne Hiller
Top achievements
Rank 1
Iron
Wayne Hiller asked on 01 Apr 2021, 03:10 PM

Blazor WebAssembly on .Net 5

After updating Telerik.UI.For.Blazor to version 2.23.0 I often see an error in the Console "Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined)." after doing a build and refreshing the page. If I then refresh the page again the error will not reappear.

I am only using the TelerikGrid.

 

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
      Error: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
          at https://localhost:44359/_framework/blazor.webassembly.js:1:1287
          at Array.forEach (<anonymous>)
          at e.findFunction (https://localhost:44359/_framework/blazor.webassembly.js:1:1247)
          at b (https://localhost:44359/_framework/blazor.webassembly.js:1:2989)
          at https://localhost:44359/_framework/blazor.webassembly.js:1:3935
          at new Promise (<anonymous>)
          at Object.beginInvokeJSFromDotNet (https://localhost:44359/_framework/blazor.webassembly.js:1:3908)
          at Object.w [as invokeJSFromDotNet] (https://localhost:44359/_framework/blazor.webassembly.js:1:64232)
          at _mono_wasm_invoke_js_blazor (https://localhost:44359/_framework/dotnet.5.0.4.js:1:190800)
          at do_icall (<anonymous>:wasm-function[10596]:0x194e4e)
Microsoft.JSInterop.JSException: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
Error: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
    at https://localhost:44359/_framework/blazor.webassembly.js:1:1287
    at Array.forEach (<anonymous>)
    at e.findFunction (https://localhost:44359/_framework/blazor.webassembly.js:1:1247)
    at b (https://localhost:44359/_framework/blazor.webassembly.js:1:2989)
    at https://localhost:44359/_framework/blazor.webassembly.js:1:3935
    at new Promise (<anonymous>)
    at Object.beginInvokeJSFromDotNet (https://localhost:44359/_framework/blazor.webassembly.js:1:3908)
    at Object.w [as invokeJSFromDotNet] (https://localhost:44359/_framework/blazor.webassembly.js:1:64232)
    at _mono_wasm_invoke_js_blazor (https://localhost:44359/_framework/dotnet.5.0.4.js:1:190800)
    at do_icall (<anonymous>:wasm-function[10596]:0x194e4e)
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__15`1[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Telerik.Blazor.Components.Dialog.DialogBuilder.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

 

 

6 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 01 Apr 2021, 03:12 PM

Hi Wayne,

Please try the steps from this article: https://docs.telerik.com/blazor-ui/troubleshooting/js-errors

Regards,
Marin Bratanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Yoly
Top achievements
Rank 2
answered on 13 Apr 2021, 11:23 PM

I'm getting the same error after upgrading, also on .Net 5. The provided troubleshooting link didn't help.

I downgraded back to 2.22 and the error is gone.

Any info on how to solve this specific error?

Unhandled exception rendering component: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).

 

Thanks.

1
Marin Bratanov
Telerik team
answered on 14 Apr 2021, 04:58 AM

Hi Yoly,

This is definitely a wrong JS Interop file being used in the browser.

Clearing the browser cache should help.

If it is a build issue with the build caching old assets, deleting the bin and obj folders will help (then clear the browser cache too).

If you are not using the static assets but the cdn, make sure to update its URL too to point to the new package version as well.

If neither of this helps, please open a support ticket with the sample project that has the problem.

Regards,
Marin Bratanov
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Browser cache fixed it, thanks!
- by
Jeremy
Top achievements
Rank 1
on 14 May 2021, 04:17 PM
0
Yoly
Top achievements
Rank 2
answered on 14 Apr 2021, 02:30 PM

Hi Marin,

It seems it was a browser cache issue. I had previously done clean/rebuild and it didn't help, clearing the browser cache as you suggested fixed the issue.

Thanks for the help!

0
Wayne Hiller
Top achievements
Rank 1
Iron
answered on 05 May 2021, 02:11 PM
I had removed the defer when loading the js file and it seemed to help a little but the issue still happens a lot. Seems like there is a timing issue, sometimes it loads in time, other times not.
You can try moving the script earlier in the page, e.g., in the <head> to give the browser more time to parse it. Without the defer attribute, putting it above the framework script should let the browser parse all the Telerik code before the app has had the chance to really initialize and so it should not throw errors anymore.
- by
Marin Bratanov
Telerik team
on 05 May 2021, 05:53 PM
It is already the first script load in the head
- by
Wayne Hiller
Top achievements
Rank 1
Iron
on 05 May 2021, 06:33 PM
If you are using the CDN, try using the static assets, such errors are not expected if the versions match, and when the CDN is used its URL must match the version of the package in the project, and that's often overlooked when upgrading.
- by
Marin Bratanov
Telerik team
on 06 May 2021, 06:35 AM
0
Wayne Hiller
Top achievements
Rank 1
Iron
answered on 06 May 2021, 01:07 PM
<script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script>

Well It ended up that I still had the defer, This project was copied from a base project and I forgot to remove it in this one (I have multiple projects using Telerik in Blazor). I will try it without the defer and see how it goes.
I hope that helps
- by
Marin Bratanov
Telerik team
on 06 May 2021, 01:17 PM
Asked by
Wayne Hiller
Top achievements
Rank 1
Iron
Answers by
Marin Bratanov
Telerik team
Yoly
Top achievements
Rank 2
Wayne Hiller
Top achievements
Rank 1
Iron
Share this question
or