This is a migrated thread and some comments may be shown as answers.

Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).

6 Answers 1616 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Wayne Hiller
Top achievements
Rank 1
Veteran
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.

Giuseppe
Top achievements
Rank 1
commented on 19 Jul 2021, 01:08 PM

Hi Marin. We also ran into this issue. Is there something speaking against using <script src="/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" asp-append-version="true"></script> ?
Dimo
Telerik team
commented on 22 Jul 2021, 09:12 AM

Hi Giuseppe,

As long as the <script> declaration has no defer attribute, it should be a blocking script and force the browser to load the file before parsing the rest of the DOM. So, I don't expect the asp-append-version attribute to cause problems.

Are you saying that you get a JavaScript error only when you have the asp-append-version="true" attribute to our JS file? Does the error occur only once after you clear the browser cache? Or does it always occur the first time the app is opened in the browser?

Can you show us where exactly the JavaScript file is registered in the page markup? Also, what do you observe in the browser's Network tab when the error occurs - is the file not loaded at all, or is it loaded for too long?

Giuseppe
Top achievements
Rank 1
commented on 22 Jul 2021, 09:18 AM

Hi Dimo. Acutally I had the defer attribute in it, so I removed it. I just wanted to ensure that with asp-append-version the browsers take the newest version we we release and not running into browser caching problems. (I asked because some scripts having troubles if there's ?xy=xx in the end of it.)
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.

2
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.

Jeremy
Top achievements
Rank 1
commented on 14 May 2021, 04:17 PM

Browser cache fixed it, thanks!
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
Veteran
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.
Marin Bratanov
Telerik team
commented on 05 May 2021, 05:53 PM

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.
Wayne Hiller
Top achievements
Rank 1
Veteran
Iron
commented on 05 May 2021, 06:33 PM

It is already the first script load in the head
Marin Bratanov
Telerik team
commented on 06 May 2021, 06:35 AM

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.
0
Wayne Hiller
Top achievements
Rank 1
Veteran
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.
Marin Bratanov
Telerik team
commented on 06 May 2021, 01:17 PM

I hope that helps
Tags
General Discussions
Asked by
Wayne Hiller
Top achievements
Rank 1
Veteran
Iron
Answers by
Marin Bratanov
Telerik team
Yoly
Top achievements
Rank 2
Wayne Hiller
Top achievements
Rank 1
Veteran
Iron
Share this question
or