Skip to content

[browser][MT] WasmEnableThreads=true should fail without workload installed #98496

@SteveSandersonMS

Description

@SteveSandersonMS

Description

The wasm-tools workload is required to build a multithreading-enabled WebAssembly app.

By default, people do not have the wasm-tools workload installed. In this scenario, if they create a Blazor WebAssembly app and set <WasmEnableThreads>true</WasmEnableThreads>, then it will fail at runtime as follows:

image

This doesn't help the developer to understand the problem or how to fix it.

Reproduction Steps

Using an SDK without wasm-tools, create a .NET 9 Blazor WebAssembly Standalone app, set <WasmEnableThreads>true</WasmEnableThreads>, and dotnet run.

Expected behavior

Ideally it would fail at build time with a message like WasmEnableThreads is set to true, but the wasm-tools workload is not installed. To build this project, first run 'dotnet workload install wasm-tools'.

The second best behavior would be failing at runtime with a message like the above.

Actual behavior

Currently it fails saying "Can't find method ... InstallMainSynchronizationContext", giving no clue how to fix it.

Regression?

No

Known Workarounds

n/a

Configuration

.NET 9 + WebAssembly

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions