0

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

1 Answer 1

0

I will suggest to check if your compiler is correctly generating in the correct path the .pdb file associated with the cs file you want to debug due this message "Didn't find associated module for /path/to/module/file.cs". Also you can check if all dll´s with pdb files are in the same path.

Sign up to request clarification or add additional context in comments.

1 Comment

The .pdb files are generated and loaded (with the DLLs) without any problems. If I reference the module projects directly from the shell, then debugging works as expected. I think it has something to do with the fact that those files are not accessed/loaded via the file system but are instead downloaded with HttpClient.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.