How can I resolve a mono_wasm_set_is_debugger_attached error in published Blazor WASM app on Edge?

T K 1 Reputation point
2023-03-23T11:37:49.34+00:00

In the latest version of Microsoft Edge I have an issue where a published Blazor WASM (.NET 6) application it getting errors on launch:

Assertion failed: Cannot call unknown function mono_wasm_set_is_debugger_attached, make sure it is exported

As far as I can tell this is Edge trying to attach the debugger, which is controlled server side in the start-up with the code:

if (app.Environment.IsDevelopment())
{
    app.UseMigrationsEndPoint();
    app.UseWebAssemblyDebugging();
}

However, I'm getting this error on a production system in Azure where the App Environment is set to "LIVE"

How can I resolve this error? Why is a production published version trying to attach to a debugger? (Is this an artefact of running Edge on a development machine?)

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,149 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,401 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 13,170 Reputation points
    2023-03-23T20:54:31.54+00:00

    The error message you're seeing is related to the Mono runtime, which is used to run the .NET code in the Blazor WebAssembly application. The error indicates that the Mono runtime is expecting a function called mono_wasm_set_is_debugger_attached to be exported, but it cannot find it.

    This error can occur when the WebAssembly application is being run in a browser that is attempting to attach a debugger, but the function is not actually exported by the application.

    To resolve this issue, you can try disabling the WebAssembly debugging feature in your production environment. You can do this by removing the app.UseWebAssemblyDebugging(); line from your code.

    Alternatively, you can try setting the ASPNETCORE_ENVIRONMENT environment variable to "Production" on your production server. This should prevent the app.UseWebAssemblyDebugging() line from being executed, even if the code is still present in your application.

    It's also possible that the issue is related to the specific version of the Mono runtime that is being used by your application. You may want to try updating to the latest version of .NET 6 and/or Mono to see if that resolves the issue.

    1 person found this answer helpful.