Skip to content

.NET 8 blazor .wasm Lazy Loaded Assemblies throws runtime exception and fails to load #95381

@fingers10

Description

@fingers10

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:

  1. Updated all the <BlazorWebAssemblyLazyLoad Include="{ASSEMBLY}.dll" /> in Web.csproj to <BlazorWebAssemblyLazyLoad Include="{ASSEMBLY}.wasm" />
  2. Updated all the await AssemblyLoader.LoadAssembliesAsync(new[] { "{ASSEMBLY}.dll" }); in App.razor to await 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

  1. Clone main branch of ilovedotnet repo.
  2. Go to commit a6a5dca35abe1b9182f6c497a34d03a5635760bc.
  3. Update to .NET 8.
  4. Run using VisualStudio 2022 17.8.1 or dotnet run command.
  5. Access from browser.
    image
  6. Clear Site Data under Application Tab in browser.
  7. Reload the home page and navigate to any article
    image

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& )

Error Screen shot:
image

.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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions