icsharpcode / ILSpy

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

failure within LoadedAssembly.LoadSymbols processing C++/CLI assembly #429

Closed Rubidium37 closed 7 years ago

Rubidium37 commented 11 years ago

Hi.

I'm experiencing a decompilation error where ILSpy fails to process debug symbols from an pure C++/CLI assembly (x86).

The failure occurs only if the option "Use variable names from debug symbols, if available" is checked and the DLL is compiled with debug symbols.

The decompilation fails with the following exception message shown inside the right pane: System.ArgumentException: An item with the same key has already been added. in System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) in Mono.Cecil.Pdb.PdbReader.PopulateFunctions() in Mono.Cecil.Pdb.PdbReader.ProcessDebugHeader(ImageDebugDirectory directory, Byte[] header) in Mono.Cecil.ModuleDefinition.ProcessDebugHeader() in ICSharpCode.ILSpy.LoadedAssembly.LoadSymbols(ModuleDefinition module) in ICSharpCode.ILSpy.LoadedAssembly.LoadAssembly() in System.Threading.Tasks.Task1.InvokeFuture(Object futureAsObj) in System.Threading.Tasks.Task.Execute()

The C++ code do heavy use of template classes, template functions and generics. It does not depend on particular external assemblies (referenced assemblies are the default ones). Custom project settings I have tried are:

No obfuscation is applied I already tried cleaning both the output and intermediate folders.

I'm using ILSpy version 2.1.0.1603 on Windows x64. I already tried to debug run ILSpy from source code and found the error being generated from Mono.Cecil.Pdb assembly (as exception trace told) using PdbFunction.token as the duplicate key in the dictionary. The error occurs also with the latest Mono.Cecil assemblies (0.9.4) fetched through NuGet package manager.

Regards, Daniele Rota Nodari.

dgrunwald commented 7 years ago

The new decompiler engine (which just landed on the master branch) uses a new Cecil version (0.10), which fixes many problems loading .PDBs. I'm closing this issue on the assumption that this fixes the problem; please re-open if there is still an issue.