Skip to content

Blazor Wasm PWA with AOT, publish build is not working after upgrade to .NET 9 #111663

Description

@PhilippJR

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Last week, I upgraded my Blazor Wasm PWA from .NET 7 to .NET 9. I tested everything, created a publish build and published it. It works without any problems.
So, I continued the work on the app and wanted to test something today. To do so, I created a publish build with <RunAOTCompilation>false</RunAOTCompilation>, simply because compilation is faster without AOT. The build was successful but the app cannot be loaded in the browser. One error message says, that Blazored.LocalStorage throws a Not Implemented Yet exception:

MONO interpreter: NIY encountered in method Blazored.LocalStorage.ServiceCollectionExtensions:AddBlazoredLocalStorage (Microsoft.Extensions.DependencyInjection.IServiceCollection)

So, I already started a bug report at the Blazored.LocalStorage github repo, but then found out that this package cannot be the (only) reason for the error. Let me explain:
In this case, 3 things can make the app crash:

  • I modified the code,
  • Blazored.LocalStorage is not ready for .NET 9 and
  • I changed with/without AOT

I tested all 8 combinations (with/without code changes, with/without Blazored.LocalStorage, with/without AOT). The only 2 cases, I can make the app run, are

  • without changes, without AOT, without Blazored.LocalStorage
  • with changes, without AOT, without Blazored.LocalStorage

Okay, it only works without Blazored.LocalStorage. That's why I first thought, this package causes the error. But it also does not work

  • without changes, with AOT, without Blazored.LocalStorage

So, I tried to go back to .NET 7, but without success. I cannot make the app run. That's a severe problem, because I cannot publish updates currently.

Here are some error messages

MONO interpreter: NIY encountered in method Blazored.LocalStorage.ServiceCollectionExtensions:AddBlazoredLocalStorage (Microsoft.Extensions.DependencyInjection.IServiceCollection) dotnet.runtime.o8gq1i8bk6.js:3 [MONO] * Assertion: should not be reached at /__w/1/s/src/mono/mono/mini/interp/interp.c:3965

Error
at Fc (https://[...].netlify.app/_framework/dotnet.runtime.o8gq1i8bk6.js:3:168644)
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[8300]:0x1faf36
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[792]:0x3e9ad
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[713]:0x3ca50
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[717]:0x3cb71
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[720]:0x3cbda
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[93]:0x7e8d
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[130]:0x16b93
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[2902]:0xcfdb8
at https://[...].netlify.app/_framework/dotnet.native.8uqnh0fgel.wasm:wasm-function[2266]:0xa6af7
Fc @ dotnet.runtime.o8gq1i8bk6.js:3
blazor.webassembly.js:1
ExitStatusmessage: "Program terminated with exit(1)"name: "ExitStatus"status: 1[[Prototype]]: Object

dotnet.runtime.o8gq1i8bk6.js:3 [MONO] /__w/1/s/src/mono/mono/mini/aot-runtime.c:2139 Error at Fc (https://neon-rabanadas-970146.netlify.app/_framework/dotnet.runtime.o8gq1i8bk6.js:3:168644) at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[77113]:0x1589a96 at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[69624]:0x13be1ea at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[69547]:0x13bc122 at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[69549]:0x13bc1ef at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[69550]:0x13bc225 at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[71818]:0x145b471 at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[70066]:0x13dcfd0 at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[70071]:0x13dd9cc at https://neon-rabanadas-970146.netlify.app/_framework/dotnet.native.xw1lrtwtqd.wasm:wasm-function[70063]:0x13dccbb Fc @ dotnet.runtime.o8gq1i8bk6.js:3 dotnet.runtime.o8gq1i8bk6.js:3 MONO_WASM: mono_wasm_load_runtime () failed [object Object] Pe @ dotnet.runtime.o8gq1i8bk6.js:3 dotnet.runtime.o8gq1i8bk6.js:3 Uncaught (in promise) ExitStatus dotnet.runtime.o8gq1i8bk6.js:3 Uncaught (in promise) ExitStatus blazor.webassembly.js:1 Uncaught (in promise) Error: Failed to start platform. Reason: [object Object] at qt (blazor.webassembly.js:1:55616)

There is a bug report, that is similar to mine, but no solution is provided.

Any help is highly appreciated, because I cannot continue working.
Please let me know, if you need any information.

Many thanks

Philipp

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

9

Anything else?

No response

Activity

  1. KristofferStrube commented on Jan 15, 2025

    @KristofferStrube

    Hey @PhilippJR, could you provide a minimal repository that shows the problem? This might help find the reason for your problem faster.

  2. PhilippJR commented on Jan 16, 2025

    @PhilippJR
    Author

    Thanks @KristofferStrube.
    I spent the whole day with creating the minimal repo. I created a new branch to do so and deleted everything that is not necessary. Then, I tested the four cases (still in the original repo)

    1. with Blazored.LocalStorage, with AOT
    2. with Blazored.LocalStorage, without AOT
    3. without Blazored.LocalStorage, with AOT
    4. without Blazored.LocalStorage, withoutAOT

    I always published the build and it is reproducible that only combination 4 can be loaded. The error messages are

    Combination 1 dotnet.runtime.rubq0v1yiy.js:3 [MONO] /__w/1/s/src/mono/mono/mini/aot-runtime.c:2139 Error at Fc (https://[...]/_framework/dotnet.runtime.rubq0v1yiy.js:3:168644) at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[74571]:0x1418633 at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[67085]:0x124cdb5 at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[67008]:0x124aced at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[67010]:0x124adba at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[67011]:0x124adf0 at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[69276]:0x12ea025 at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[67527]:0x126bb9b at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[67532]:0x126c597 at https://[...]/_framework/dotnet.native.w8nw0z0o5n.wasm:wasm-function[67524]:0x126b886 dotnet.runtime.rubq0v1yiy.js:3 MONO_WASM: mono_wasm_load_runtime () failed [object Object] dotnet.runtime.rubq0v1yiy.js:3 Uncaught (in promise) ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1, silent: true} dotnet.runtime.rubq0v1yiy.js:3 Uncaught (in promise) ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1, silent: true} blazor.webassembly.js:1 Uncaught (in promise) Error: Failed to start platform. Reason: [object Object] at qt (blazor.webassembly.js:1:55616)
    Combination 2 dotnet.runtime.rubq0v1yiy.js:3 [MONO] * Assertion: should not be reached at /__w/1/s/src/mono/mono/mini/interp/interp.c:3965 Error at Fc ([...]/_framework/dotnet.runtime.rubq0v1yiy.js:3:168644) at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[8297]:0x1faf19 at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[792]:0x3e9a4 at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[713]:0x3ca47 at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[717]:0x3cb68 at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[720]:0x3cbd1 at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[93]:0x7e84 at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[130]:0x16b8a at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[2899]:0xcfd9b at https://[...]/_framework/dotnet.native.1odv868sed.wasm:wasm-function[2266]:0xa6af0 blazor.webassembly.js:1 ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1}
    Combination 3 dotnet.runtime.rubq0v1yiy.js:3 [MONO] /__w/1/s/src/mono/mono/mini/aot-runtime.c:2139 Error at Fc ([...]/_framework/dotnet.runtime.rubq0v1yiy.js:3:168644) at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[74212]:0x1401d38 at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[66726]:0x12364c6 at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[66649]:0x12343fe at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[66651]:0x12344cb at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[66652]:0x1234501 at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[68917]:0x12d3736 at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[67168]:0x12552ac at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[67173]:0x1255ca8 at https://[...]/_framework/dotnet.native.hsxvpdpqyt.wasm:wasm-function[67165]:0x1254f97 dotnet.runtime.rubq0v1yiy.js:3 MONO_WASM: mono_wasm_load_runtime () failed [object Object] dotnet.runtime.rubq0v1yiy.js:3 Uncaught (in promise) ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1, silent: true} dotnet.runtime.rubq0v1yiy.js:3 Uncaught (in promise) ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1, silent: true} blazor.webassembly.js:1 Uncaught (in promise) Error: Failed to start platform. Reason: [object Object] at qt (blazor.webassembly.js:1:55616)

    Next, I created a new public repo, cloned it and copied alle the files from my original project into it. That's what you asked for, but when I tested the published versions of this minimal example repo, all four combinations worked well.

    Here's the link to the minimal repo anyway, although I do not think that it will help.
    I think, that anything else is wrong with my original repo. Any ideas?

    Thanks again!

    Philipp

  3. PhilippJR commented on Jan 17, 2025

    @PhilippJR
    Author

    I made it :-)
    I still do not know, what exactly caused this issue, but in case anyone faces the same problem, here are my steps. If the solution comprises several projects, like in my case, do the following steps in each project folder. It is probably smart to create a backup first. Also, please note, that e. g. the publish profile will be deleted.

    1. Open the Developer PowerShell. Open it in Windows not in Visual Studio as later some files must be deleted, what is not possible when Visual Studio is running.
    2. Navigate to the folder(s) with the solution file(s) (.sln).
    3. Run "dotnet clean".
    4. Again in all folders run "dotnet restore --no-cache".
    5. Run "git clean -xdf" in all folders.
    6. In the folder with the main solution run "dotnet restore" and "dotnet build".

    After these steps, I was finally able to create executable publish builds for above mentioned combinations 1 and 2. (3 and 4 are not really relevant, so I did not test them.)

  4. transferred this issue fromdotnet/aspnetcoreon Jan 21, 2025
  5. digitaldirk commented on Feb 20, 2025

    @digitaldirk

    @PhilippJR I was encountering the same error only when my Blazor wasm project was published. It was a brand new .net 9 wasm standalone project with a few additions, after I followed your steps and restarting my pc/visual studio the publish worked.

    Thanks!

  6. dotnet-policy-service commented on Feb 20, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing
    See info in area-owners.md if you want to be subscribed.

  7. self-assigned this
    on Feb 20, 2025
  8. e0548965 commented on Feb 27, 2025

    @e0548965

    Thanks @PhilippJR really helped me

  9. vellad001 commented on Mar 20, 2025

    @vellad001

    @PhilippJR! Experienced the same issue today and was able to solve the issue using your solution. Thanks!

  10. assigned and unassigned on Mar 21, 2025
  11. pavelsavara commented on Apr 1, 2025

    @pavelsavara
    Member

    The root cause is that our MSBuild scripts are not smart enough to understand when to do full clean of bin and obj folder. Sorry about that.

    The "solution" is to do full clean yourself, any time you upgrade SDK or any time you make changes to project (MSBuild) properties.

  12. added this to the Future milestone on Jun 16, 2025
  13. ZzZombo commented on Jul 15, 2025

    @ZzZombo

    This was the only thing that saved me from basically scrapping the whole thing and looking for an alternative. I was ready to even consider forgoing .NET completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions