I'm building a modular Blazor WebAssembly application where separate Razor Class Libraries "modules" are loaded as plugins at runtime. These modules are not referenced by the main Blazor WebAssembly project "shell" to separate module development from the shell.
Current Approach:
- Modules are compiled independently (currently within the same solution).
- Module's DLLs and PDBs are served to the shell via an API.
- The shell application dynamically loads these modules using AssemblyLoadContext.Default.LoadFromStream(dllStream, pdbStream).
Goal: I need to enable debugging of the dynamically loaded modules when the debugger is attached to the Blazor WebAssembly (shell) process (in docker). Module developers should be able to build their modules independently, provide the DLLs/PDBs to the API, and then debug their code by attaching it to the running shell.
Environment:
- .NET 9
- Blazor WebAssembly
- Rider (Visual Studio works as expected)
Question: Is the following even possible? What should I do differently to achieve working debugging?
Example code:
// AssemblyLoader.cs
public async Task<List<Assembly>> LoadAdditionalAssemblies()
{
var dll = await _httpClient.GetAsync("Modules/ModuleExample/ModuleExample.dll");
var pdb = await _httpClient.GetAsync("Modules/ModuleExample/ModuleExample.pdb");
await using var dllStream = await dll.Content.ReadAsStreamAsync();
await using var pdbStream = await pdb.Content.ReadAsStreamAsync();
var assembly = AssemblyLoadContext.Default.LoadFromStream(dllStream, pdbStream);
return [assembly];
}
Example tiny project: Github repo
Problem: Debugging does not work as expected. When I attempt to set a breakpoint in a module's code, IDE Rider displays one of the following messages:
- "/path/to/module/file.cs is not found among the loaded symbol documents"
- "Didn't find associated module for /path/to/module/file.cs"
The module is not listed in the Debug-Modules list, only the shell is there (debugging works in the shell).