Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

.NET 10 Blazor WebAssembly – Calling C# from JavaScript no longer works (JSInvokable / JSExport / createDotNetRuntime)

$
0
0

I’m building an Android application that needs to execute C# code from DLLs via WebAssembly. With .NET 9, everything works fine using this approach:

  • Blazor WebAssembly project
  • C# methods decorated with [JSInvokable]
  • Build the project → get the /framework folder
  • Copy /framework into the Angular app
  • Call C# from JavaScript using: DotNet.invokeMethodAsync("MyAssembly", "MyMethod")

After upgrading the C# projects to .NET 10, the whole setup breaks.

It looks like Blazor WebAssembly / JS interop internals have changed significantly and I can no longer call C# methods from my Angular app.

What I tried

  1. [JSInvokable] (Blazor-style interop) no longer works; DotNet.invokeMethodAsync fails. The runtime initialization seems different / missing.

  2. [JSExport] (Native WASM interop). I tried the “new” recommended approach: dotnet publish -c Release -r browser-wasm. This produces .wasm and .js files; [JSExport] methods are compiled correctly, but when calling it from Angular, I get:

    createDotNetRuntime is not defined

How can I call or load the .NET WASM runtime in a .NET 10 app? Or is there a replacement for DotNet.invokeMethodAsync?

Downgrading back to .NET 9 is not a viable long-term solution.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>