Skip to content

Generating PDB throws System.ArgumentException: An item with the same key has already been added. #2185

@cateyes99

Description

@cateyes99

I found that #2177 has been fixed in ILSpy 6.3.0.6139-preview1, sweet. While further trying PDB generation with different C# version options, found there is another issue occurred both in ILSpy 6.2.0.6124, & 6.3.0.6139-preview1.

Steps to reproduce

  1. Try to generate PDB for Newtonsoft.Json.dll 12.0.3 by setting C# Version to C# 2.0, C# 3.0, C# 4,0, C# 5.0 or C# 6.0 each time. Both ILSpy 6.2.0.6124, & 6.3.0.6139-preview1 throw System.ArgumentException: An item with the same key has already been added..
  2. But by setting to other C# Versions (C# 1.0, C# 7.0, C# 7.1, C# 7.2, C# 7.3, C# 8.0, or C# 9.0), PDB generation works fine.

Error message shown

System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at ICSharpCode.Decompiler.DebugInfo.PortablePdbWriter.<>c__DisplayClass2_0.<WritePdb>g__ProcessMethod|7(MethodDefinitionHandle method, DocumentHandle document, List`1 sequencePoints, SyntaxTree syntaxTree) in C:\Source\GitHub\ILSpy\ICSharpCode.Decompiler\DebugInfo\PortablePdbWriter.cs:line 220
   at ICSharpCode.Decompiler.DebugInfo.PortablePdbWriter.WritePdb(PEFile file, CSharpDecompiler decompiler, DecompilerSettings settings, Stream targetStream, Boolean noLogo) in C:\Source\GitHub\ILSpy\ICSharpCode.Decompiler\DebugInfo\PortablePdbWriter.cs:line 116
   at ICSharpCode.ILSpy.GeneratePdbContextMenuEntry.<>c__DisplayClass3_0.<GeneratePdbForAssembly>b__2() in C:\Source\GitHub\ILSpy\ILSpy\Commands\GeneratePdbContextMenuEntry.cs:line 81
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

image

Details

  • Product in use: e.g. ILSpy
  • Version in use: 6.2.0.6124, & 6.3.0.6139-preview1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions