Repository navigation
Closed
Labels
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have my production blazor wasm app running on .NET 7 with lazy loading enabled. Now I'm updating my blazor wasm app to .NET 8 following the docs. And when I run, I'm surprised to see a run time exception and the assemblies are not loaded.
Steps I did:
- Updated all the
<BlazorWebAssemblyLazyLoad Include="{ASSEMBLY}.dll" />inWeb.csprojto<BlazorWebAssemblyLazyLoad Include="{ASSEMBLY}.wasm" /> - Updated all the
await AssemblyLoader.LoadAssembliesAsync(new[] { "{ASSEMBLY}.dll" });inApp.razortoawait AssemblyLoader.LoadAssembliesAsync(new[] { "{ASSEMBLY}.wasm" });
Expected Behavior
The app should lazy load the assemblies and run them like before in .NET 7. Here is the working main branch of ilovedotnet repo.
Steps To Reproduce
- Clone main branch of ilovedotnet repo.
- Go to commit a6a5dca35abe1b9182f6c497a34d03a5635760bc.
- Update to .NET 8.
- Run using
VisualStudio 2022 17.8.1ordotnet run command. - Access from browser.

Clear Site DataunderApplicationTab in browser.- Reload the home page and navigate to any article

Exceptions (if any)
Runtime Error:
Unhandled exception rendering component: Could not load file or assembly 'Components, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
System.IO.FileNotFoundException: Could not load file or assembly 'Components, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
IO_FileName_Name, Components, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__6_0(RenderTreeBuilder builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder , RenderFragment , Exception& )
.NET Version
8.0.100
Anything else?
dotnet --info:
.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.100-manifests.8d38d0cc
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.100\
.NET workloads installed:
Workload version: 8.0.100-manifests.8d38d0cc
[wasm-tools-net7]
Installation Source: SDK 8.0.100
Manifest Version: 8.0.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.net7\8.0.0\WorkloadManifest.json
Install Type: Msi
[ios]
Installation Source: VS 17.8.34316.72
Manifest Version: 17.0.8478/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.0.8478\WorkloadManifest.json
Install Type: Msi
[android]
Installation Source: VS 17.8.34316.72
Manifest Version: 34.0.43/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.43\WorkloadManifest.json
Install Type: Msi
[maui-windows]
Installation Source: VS 17.8.34316.72
Manifest Version: 8.0.3/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json
Install Type: Msi
[wasm-tools]
Installation Source: VS 17.8.34316.72
Manifest Version: 8.0.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.0\WorkloadManifest.json
Install Type: Msi
[maccatalyst]
Installation Source: VS 17.8.34316.72
Manifest Version: 17.0.8478/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.0.8478\WorkloadManifest.json
Install Type: Msi
Host:
Version: 8.0.0
Architecture: x64
Commit: 5535e31a71
.NET SDKs installed:
8.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Visual Studio:
Microsoft Visual Studio Enterprise 2022 (64-bit) - Current
Version 17.8.1
Windows:
Edition Windows 11 Pro
Version 21H2
Installed on 10-11-2021
OS build 22000.2538
Experience Windows Feature Experience Pack 1000.22001.1000.0
Activity
[-].NET 8 .wasm Lazy Loaded Assemblies throws runtime exception and fails to load[/-][+].NET 8 blazor .wasm Lazy Loaded Assemblies throws runtime exception and fails to load[/+]fingers10 commentedon Nov 27, 2023
@mkArtakMSFT I have added the repo to reproduce issue in steps to reproduce
Sean4572435243 commentedon Nov 28, 2023
This helped me; specifically the ToList() addition:
dotnet/aspnetcore#52162 (comment)
fingers10 commentedon Nov 29, 2023
@Sean4572435243 I'm still not able to figure out what I'm missing.
Here is my
.csproj:Here is my
App.razor:I dont have any routable components inside other assemblies. So I didnt add anything in
AdditionalAssembliesinRouter. Please can you assist me?fingers10 commentedon Nov 29, 2023
I figured it out. The issue in my case is that I was having
RCLnamedComponents.csproj. This is causing the trouble. Not sure if the nameComponentsis a reserved word which should not be used as project name. I understood from this issue - #95169 that there is a collision in lazy loading when using certain types of names.I renamed my project from
Components.csprojtoBaseComponents.csprojand updated the references everywhere..csproj:App.razor:This resolved my issue.
But this is no where documented on what kind of names should not be used. Or there should be an alternate alias naming option should be provided to overcome this issue.
javiercn commentedon Nov 29, 2023
@fingers10 thanks for the additional details.
I'm not sure how the rename has helped/fixed anything in this case. There are no "reserved" names that shouldn't be used afaik that would not cause your c# compilation to fail.
I'm moving this to the runtime in case they want to take a look, but it doesn't seem that this is an issue in the framework, rather something in the app/upgrade process.
maraf commentedon Dec 13, 2023
I was able reproduce the issue. The problem is that we are trying to search in already loaded assemblies by "contains" in assembly name, not "exact match"
runtime/src/mono/wasm/runtime/lazyLoading.ts
Line 24 in 32027b8
The blazor framework contains
Microsoft.AspNetCore.Components.wasmand soComponents.wasmgets incorrectly marked as already loadedfingers10 commentedon Dec 13, 2023
Wow @maraf many thanks for the support and findings.