icsharpcode / ILSpy

.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
21.46k stars 3.35k forks source link

Can't create pdb from assembly, doesn't contain PE Debug Directory Entry #2973

Closed Meister1593 closed 1 year ago

Meister1593 commented 1 year ago

Not sure if i understand what this means, or why it wouldn't create it, maybe i'm not understanding something obvious? In general, my overall idea is to attach debugger (rider in my case) and have a debug symbols for the attached application assemblies to see code. The first part of attaching game i already completed, but without symbols it's not very useful, and rider doesn't generate them by itself. I tried using dotpeek, but it doesn't really want to run under wine, so while looking at solutions, ilspy seemed most promising for that purpose.

Steps to reproduce

It seems quite random, but it happens for some Dll's, but not for others. In my case, i tried to generate pdb for game files (NeosVR) and some assemblies works and they generate pdb files (CodeX.dll from Managed folder), but some don't (FrooxEngine.dll for instance) Since this is a someone's product, i probably can't really redistribute dlls, but they are stored with it and it's free. There is also a link for a standalone version with same links outside steam, but not sure if it would be needed.

Error message shown

image

Details

trivalik commented 1 year ago

The pdb create is blocked, the question is why: see https://github.com/icsharpcode/ILSpy/blob/fa900be124cf2997e9d60d3bf0a5735cad572625/ILSpy/Commands/GeneratePdbContextMenuEntry.cs#L62

edit:

Here the result without the check:

System.ArgumentException: The Debug directory was not of type CodeView. (Parameter 'entry')
   at System.Reflection.Throw.InvalidArgument(String message, String parameterName)
   at System.Reflection.PortableExecutable.PEReader.ReadCodeViewDebugDirectoryData(DebugDirectoryEntry entry)
   at ICSharpCode.Decompiler.DebugInfo.PortablePdbWriter.WritePdb(PEFile file, CSharpDecompiler decompiler, DecompilerSettings settings, Stream targetStream, Boolean noLogo, Nullable`1 pdbId, IProgress`1 progress) in C:\Users\trivalik\source\repos\ILSpy\ICSharpCode.Decompiler\DebugInfo\PortablePdbWriter.cs:line 240
   at ICSharpCode.ILSpy.GeneratePdbContextMenuEntry.<>c__DisplayClass3_1.<GeneratePdbForAssembly>b__2() in C:\Users\trivalik\source\repos\ILSpy\ILSpy\Commands\GeneratePdbContextMenuEntry.cs:line 84
   at System.Threading.Tasks.Task`1.InnerInvoke()
trivalik commented 1 year ago

As we found out in the PR that for assemblies built without an pdb it is not possible to load a pdb in Visual Studio. This makes this bug report pointless and should be closed.