dotnet / dotnet/runtime

Working WASM project migrated to .NET 10 - 'MONO interpreter: NIY encountered in method' or 'Your mono runtime and class libraries are out of sync'

Open
#121,849 8 comments 0 reactions 0 assignees View on GitHub
arch-wasm area-Build-mono os-browser
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

I originally posted as a comment on this other issue which seems related: #121840

I have now spent 3 days trying different combinations of settings in the .csproj and I always end up with one of the following errors.

This is an existing, mature project, using .NET 9 that has just been migrated to .NET 10. Right from the end of the migration, using exactly the same settings that used to work, we started getting errors caused by the trimmer. The project builds and runs successfully when running from within Visual Studio 2026 both in Debug and Release configurations.

Here are the original .csproj settings:

```
True

False
True


True
False


True





```

And here's the command we use to publish:

```dotnet publish ..\UI\UI.csproj --configuration Release --output C:\MyPublishDirectory --verbosity m --tl:off```

We then test the published artifacts by serving them locally using dotnet serve (something we started doing now in order to remove CDN and caching from the equation).

With those same settings we get the following runtime error:

```
MONO interpreter: NIY encountered in method BlazorApplicationInsights.IServiceCollectionExtensions:AddBlazorApplicationInsights (Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action`1,System.Func`2,bool,System.Action`1)
dotnet.runtime.o0qy896u8v.js:3 [MONO] * Assertion: should not be reached at /__w/1/s/src/runtime/src/mono/mono/mini/interp/interp.c:4130

Error
at Mc (dotnet.runtime.o0qy896u8v.js:3:172283)
...
Module._mono_wasm_invoke_jsexport @ dotnet.native.1aocdz4mc7.js:6272
wn @ dotnet.runtime.o0qy896u8v.js:3
(anonymous) @ dotnet.runtime.o0qy896u8v.js:3
Vc @ dotnet.runtime.o0qy896u8v.js:3
await in Vc
callEntryPoint @ blazor.webassembly.66stpp682q.js:1
qt @ blazor.webassembly.66stpp682q.js:1
await in qt
Yt @ blazor.webassembly.66stpp682q.js:1
an @ blazor.webassembly.66stpp682q.js:1
value @ BlazorLoader.js:72
value @ AppController.jsx:211
s @ web.js:878
Te @ web.js:903

blazor.webassembly.66stpp682q.js:1 ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1}
```

Since the error seems related to trimming or "wasm build native" my strategy has been to disable anything that dotnet publish might be doing differently to a Visual Studio build, which is clearly something. However, this doesn't seem to be documented anywhere and I'm left randomly trying things:

1. Disabling AOT Compilation and WasmBuildNative (PublishAot, RunAOTCompilation and WasmBuildNative set to false) produces error "WasmApp.Common.targets(494,5): error : WasmBuildNative is required because RunAOTCompilation=false, but WasmBuildNative is alread y set to 'false'". I understand this is by design but I was desperate to disable anything that dotnet publish might be doing under the hood.
2. Leaving WasmBuildNative untouched (defaults to true) and disabling BlazorWebAssemblyEnableLinking and WasmNativeRelinking produces the same error.
3. All the above plus disabling trimming (false) results a different error (see below).

```
Your mono runtime and class libraries are out of sync.
blazor.webassembly.66stpp682q.js:1 The out of sync library is: System.Private.CoreLib.dll
blazor.webassembly.66stpp682q.js:1
blazor.webassembly.66stpp682q.js:1 When you update one from git you need to update, compile and install
blazor.webassembly.66stpp682q.js:1 the other too.
blazor.webassembly.66stpp682q.js:1 Do not report this as a bug unless you're sure you have updated correctly:
blazor.webassembly.66stpp682q.js:1 you probably have a broken mono install.
blazor.webassembly.66stpp682q.js:1 If you see other errors or faults after this message they are probably related
blazor.webassembly.66stpp682q.js:1 and you need to fix your mono install first.
blazor.webassembly.66stpp682q.js:1
blazor.webassembly.66stpp682q.js:1 Your mono runtime and class libraries are out of sync.
blazor.webassembly.66stpp682q.js:1 The out of sync library is: System.Private.CoreLib.dll
blazor.webassembly.66stpp682q.js:1
blazor.webassembly.66stpp682q.js:1 When you update one from git you need to update, compile and install
blazor.webassembly.66stpp682q.js:1 the other too.
blazor.webassembly.66stpp682q.js:1 Do not report this as a bug unless you're sure you have updated correctly:
blazor.webassembly.66stpp682q.js:1 you probably have a broken mono install.
blazor.webassembly.66stpp682q.js:1 If you see other errors or faults after this message they are probably related
blazor.webassembly.66stpp682q.js:1 and you need to fix your mono install first.
blazor.webassembly.66stpp682q.js:1 [ERROR] FATAL UNHANDLED EXCEPTION: Nested exception detected.
wt @ blazor.webassembly.66stpp682q.js:1
put_char @ dotnet.native.ywo0av6b5x.js:1369
write @ dotnet.native.ywo0av6b5x.js:1315
write @ dotnet.native.ywo0av6b5x.js:2824
doWritev @ dotnet.native.ywo0av6b5x.js:5361
_fd_write @ dotnet.native.ywo0av6b5x.js:5443
...
(anonymous) @ blazor.webassembly.66stpp682q.js:1
await in (anonymous)
Zt @ blazor.webassembly.66stpp682q.js:1
qt @ blazor.webassembly.66stpp682q.js:1
Yt @ blazor.webassembly.66stpp682q.js:1
an @ blazor.webassembly.66stpp682q.js:1
value @ BlazorLoader.js:72
value @ AppController.jsx:211
s @ web.js:878
Te @ web.js:903

blazor.webassembly.66stpp682q.js:1 Original Exception: at (wrapper managed-to-native) System.Threading.Interlocked.CompareExchange (object&,object&,object&,object&) [0x00000] in <2ce51f039573407794a9b71d8340c2cc>:0
wt @ blazor.webassembly.66stpp682q.js:1
put_char @ dotnet.native.ywo0av6b5x.js:1369
write @ dotnet.native.ywo0av6b5x.js:1315
write @ dotnet.native.ywo0av6b5x.js:2824
doWritev @ dotnet.native.ywo0av6b5x.js:5361
$mono_wasm_load_runtime @ dotnet.native.h9zhezurw2.wasm:0x22048e
...
Module._mono_wasm_load_runtime @ dotnet.native.ywo0av6b5x.js:6405
(anonymous) @ dotnet.runtime.o0qy896u8v.js:3
(anonymous) @ dotnet.runtime.o0qy896u8v.js:3

blazor.webassembly.66stpp682q.js:1 Uncaught (in promise) Error: Failed to start platform. Reason: [object Object]
```

I am now stuck without understanding what's going on or how to fix it.

Before you ask, I have tried to reproduce in a simpler project but haven't been able to :-)

### Reproduction Steps

I'm afraid I haven't been able to create a minimal reproduction. A key piece of data is that the project was working fine before migrating to .NET 10. That's the only change.

### Expected behavior

The application should execute successfully.

### Actual behavior

Depending on the settings, one of the following errors:

1. Your mono runtime and class libraries are out of sync
2. MONO interpreter: NIY encountered in method

See the description for full details.

### Regression?

Yes. This same project with these same settings works OK in .NET 9.

### Known Workarounds

I wish!

### Configuration

.NET: 10.0.100
Windows: 11
Standalone Blazor WASM
All browsers

### Other information

Looks like it's related to trimming and AOT. And the fact that it doesn't look like they can be disabled for a dotnet publish makes it impossible to work around it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.