ArxOne / MrAdvice

.NET aspect weaver (build task under NuGet package)
MIT License
311 stars 45 forks source link

PDB fails to load #200

Closed rgroenewoudt closed 9 months ago

rgroenewoudt commented 9 months ago

We are running into a rare issue. We are using MrAdvice in our large solution in most projects but in 1 or 2 projects, the .pdb file fails to load while debugging in Visual Studio.

The Modules-windows in VS simply shows that PDB is not loaded and it fails loading it: Unexpected error opening PDB file. The file may be corrupt. When MrAdvice nuget package is removed, it works again. Other similar projects always work.

The same issue occurs on my colleague's computers.

Things I've tried that make no difference:

Comparing the DLLs in DotPeek with/without MrAdvice doesn't indicate anything. The one thing that is interesting is that System.Runtime shows up twice, 6.0.0.0 and 8.0.0.0 (we are using .NET 8) but this happens in all DLLs with MrAdvice.

I cannot reproduce this in a new project.

Do you have any suggestions on how to debug this? I can build MrAdvice locally and try out different things.

Running on:

picrap commented 9 months ago

Hi,

as far as I remember, this is related to PDB format. You can change it in build properties. Another PDB format may work. Sorry for blurry answer. Let me know!

rgroenewoudt commented 9 months ago

Well, the results are interesting. I've tried the DebugType options

My guess is that MrAdvice corrupts the new portable pdb in a rare case. If I try the tool sourcelink with command sourcelink print-urls pdb-file, it works for other projects but fails with error "Read out of bounds." for the specific project. I'm cannot find any other tools to validate the portable-pdb-format.

picrap commented 9 months ago

MrAdvice is based on dnlib (https://github.com/0xd4d/dnlib) wich does the dirty work with PDB, so unfortunately this is not something I am comfortable with. If one day there is something similar directly in dotnet, it may be worth trying to port it.

rgroenewoudt commented 9 months ago

Well, good news. I just spent 10 minutes updating dnlib to latest nuget (previous version was from 2020) in the Stitcherboy project and put the binaries in MrAdvice locally and debugging now works 👍

I can make a PR for you in https://github.com/picrap/StitcherBoy.

picrap commented 9 months ago

That would be great! I’ll update MrAdvice after this. Thank you.

picrap commented 9 months ago

MrAdvice 2.15 is out! Let me know.

rgroenewoudt commented 9 months ago

Confirmed, the problem is fixed