Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cateyes99 opened this issue Oct 8, 2020 · 0 comments

Comments

@cateyes99
Copy link

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
@cateyes99 cateyes99 added the Bug label Oct 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 11, 2021
ElektroKill added a commit to dnSpyEx/ILSpy that referenced this issue Aug 9, 2021
…play structs: Async State Machines that looked like local function display structs were not hidden once local function decompilation was disabled. This led to code duplication in the generated pdb.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants