question

54626647 avatar image
0 Votes"
54626647 asked ZhiLv-MSFT commented

blazor runtime question

Is dotnet.wasm, the runtime of blazor, mono? Or did you make it yourself as part of the dotnet core?

dotnet-aspnet-core-generaldotnet-runtime
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ZhiLv-MSFT avatar image
0 Votes"
ZhiLv-MSFT answered

Hi @54626647,

Is dotnet.wasm, the runtime of blazor, mono? Or did you make it yourself as part of the dotnet core?

Please refer the official document, the software development kit (SDK) includes everything you need to build and run .NET Core applications, using command-line tools and any editor (like Visual Studio). And the asp.net core runtime includes everything you need to run .NET Core applications. The runtime is also included in the SDK.

Blazor WebAssembly is a single-page app (SPA) framework for building interactive client-side web apps with .NET, it is not the runtime of the Blazor. When a Blazor WebAssembly app is built and run in a browser:

  • C# code files and Razor files are compiled into .NET assemblies.

  • The assemblies and the .NET runtime are downloaded to the browser.

  • Blazor WebAssembly bootstraps the .NET runtime and configures the runtime to load the assemblies for the app. The Blazor WebAssembly runtime uses JavaScript interop to handle DOM manipulation and browser API calls.

More detail information, see Blazor WebAssembly.


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best Regards,
Dillion

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered BruceBarker-8516 edited

it is the mono WASM assembly.

The Blazor/mono approach is different from most WASM cross compilers. Typically a LLVM compiler is used to create a native WASM assembly. But rather than C# producing a WASM assembly, a .net WASM was produced that can run the IL code produced by a C# compiler. Javascript loads the WASM assembly. Javascript then passes IL code (.net dll) to the WASM assembly and the WASM assembly runs it. This means Blazor WASM apps are interpreted and not JIT Compiled.

As a LLVN compiler must be used to produce a WASM assembly, the mono IL WASM vm is used as it was written with a LLVM c/c++ compiler and does not require thread support.

The Blazor supporting libraries are written in C# and use the roslyn compiler, not the mono compiler. It is these runtime libraries (written in c#) that makes it compatible with net 5/6 libraries.

some of the blazor wasm runtime library support actually depends on javascript, as WASM apps runs in a sandbox. network, timer and dom access must be done via javascript. for example, the HttpClient library has to use javascript interop to make an actual network call.

also, currently thread support in WASM is experimental, so the Blazor WASM does not have true thread support. thread support is pretty key to the Microsoft .net JIT compiler and IL runtime. For example the GC runs on a thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Microsoft has a project in .net 6 to compile blazor WASM via the AoT compile of the core clr

asp-net-core-updates-in-net-6-preview-4

The blazor support is via extra compile steps

asp-net-core-updates-in-net-6-preview-4

0 Votes 0 ·
54626647 avatar image
0 Votes"
54626647 answered ZhiLv-MSFT commented

In a hurry with a translator? I think my question was misrepresented if you translate it.

What I was trying to ask was...

Is the dotnet.wasm file that allows the blazor app to run based on dotnet clr on dotnet core? Or, I was wondering if it was made of a mono base.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ZhiLv-MSFT avatar image
0 Votes"
ZhiLv-MSFT answered ZhiLv-MSFT commented

Hi @54626647,

You can refer this blog:

The default experience for most .NET 5 workloads will be using the JIT-based CoreCLR runtime. The two notable exceptions are iOS and client-side Blazor (web assembly) since both require ahead-of-time (AOT) native compilation.

The Blazor project is already using the Mono AOT. It will be one of the first projects to transition to .NET 5. We are using it as one of the scenarios to prove out this plan.


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best Regards,
Dillion

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

So, is it based on mono, but works with AOT instead of JIT, and AOT compiles while dotnet.wasm is loaded and .net assemblies are loaded?

0 Votes 0 ·

Hi @54626647,

Yes, it's based on mono and work with AOT, not sure if I understand your question correctly, but AOT is a compiling process which you can find more details in Ahead of Time Compilation (AOT) it does not happen at dotnet.wasm loading time.

0 Votes 0 ·