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

net6.0: Runtime error: invokeJSFromDotNet creating HostBuilder #38625

Closed
LukeTOBrien opened this issue Nov 24, 2021 · 2 comments
Closed

net6.0: Runtime error: invokeJSFromDotNet creating HostBuilder #38625

LukeTOBrien opened this issue Nov 24, 2021 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-jsinterop This issue is related to JSInterop in Blazor feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly

Comments

@LukeTOBrien
Copy link

Hello,

This error has ruined my entire day and as a last resort I am posting here.
My project was using net5.0 and I have recent updated to 6.0 - Are there any additional migration steps from 5 to 6?
I would also like to ask where can I find the unminified source for blazor.webassembly.js?

If you look at the bottom it say the error is on line 16 which is var builder = WebAssemblyHostBuilder.CreateDefault(args);
The stack trace also says InitializeNavigationManager - The main component is doing JS Interop inside OnAfterRenderAsync but I don't think it's getting this far.

I have absolutely no idea.
Any ideas what I can do to help solve?

The error appears at runtime in the Dev console of the browser:

(I am using Parcel for bundling, hence the filename index.abc.js)

index.6bce0794.js:1 System.AggregateException: One or more errors occurred. (n8 is not defined
ReferenceError: n8 is not defined
    at Object.Rt [as invokeJSFromDotNet] (https://localhost:7013/index.6bce0794.js:1:63608)
    at _mono_wasm_invoke_js_blazor (https://localhost:7013/_framework/dotnet.6.0.0.fkurqlj2a7.js:1:193780)
    at wasm://wasm/00945abe:wasm-function[2588]:0x8065b
    at wasm://wasm/00945abe:wasm-function[2307]:0x689a7
    at wasm://wasm/00945abe:wasm-function[7015]:0x17bac4
    at wasm://wasm/00945abe:wasm-function[6830]:0x172bc5
    at wasm://wasm/00945abe:wasm-function[3524]:0xb47cc
    at wasm://wasm/00945abe:wasm-function[675]:0x16602
    at wasm://wasm/00945abe:wasm-function[6727]:0x16f60e
    at Object.Module._mono_wasm_invoke_method [as invoke_method] (https://localhost:7013/_framework/dotnet.6.0.0.fkurqlj2a7.js:1:215575))
 ---> Microsoft.JSInterop.JSException: n8 is not defined
ReferenceError: n8 is not defined
    at Object.Rt [as invokeJSFromDotNet] (https://localhost:7013/index.6bce0794.js:1:63608)
    at _mono_wasm_invoke_js_blazor (https://localhost:7013/_framework/dotnet.6.0.0.fkurqlj2a7.js:1:193780)
    at wasm://wasm/00945abe:wasm-function[2588]:0x8065b
    at wasm://wasm/00945abe:wasm-function[2307]:0x689a7
    at wasm://wasm/00945abe:wasm-function[7015]:0x17bac4
    at wasm://wasm/00945abe:wasm-function[6830]:0x172bc5
    at wasm://wasm/00945abe:wasm-function[3524]:0xb47cc
    at wasm://wasm/00945abe:wasm-function[675]:0x16602
    at wasm://wasm/00945abe:wasm-function[6727]:0x16f60e
    at Object.Module._mono_wasm_invoke_method [as invoke_method] (https://localhost:7013/_framework/dotnet.6.0.0.fkurqlj2a7.js:1:215575)
   at Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled[Object,Object,Object,String](String identifier, Object arg0, Object arg1, Object arg2, Int64 targetInstanceId)
   at Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled[String](String identifier)
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.InitializeNavigationManager(IJSUnmarshalledRuntime jsRuntime)
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder..ctor(IJSUnmarshalledRuntime jsRuntime, JsonSerializerOptions jsonOptions)
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.CreateDefault(String[] args)
   at Program.<Main>$(String[] args) in C:\App\UI\UI\Program.cs:line 16
   --- End of inner exception stack trace ---
@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components feature-blazor-jsinterop This issue is related to JSInterop in Blazor labels Nov 24, 2021
@javiercn javiercn added the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label Nov 24, 2021
@LukeTOBrien
Copy link
Author

Just to add more detail.
I added a breakpoint to the JS file in DevTools, the attached screenshot shows the function.

It is using jsCallDispatcher.findJSFunction to call a method Blazor._internal.navigationManager.getUnmarshalledBaseURI.
The parameters n8 and r4 seem to be both undefined.

Hope this helps :)

jscall-navigationManager

@SteveSandersonMS
Copy link
Member

I would also like to ask where can I find the unminified source for blazor.webassembly.js?

It's built from TypeScript sources at https://github.com/dotnet/aspnetcore/tree/main/src/Components/Web.JS/src.

We do support customization of the deployed application file structure as described at https://devblogs.microsoft.com/dotnet/custom-deployment-layout-for-blazor-webassembly-apps/. However I'm afraid we don't specifically test for or support using the Parcel bundler and don't have any specific insights into why using that might be breaking the JavaScript file. Sorry I can't give more info here.

@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-jsinterop This issue is related to JSInterop in Blazor feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Projects
None yet
Development

No branches or pull requests

4 participants