PdbReader does not handle custom debug info for dynamic locals


Attached is a binary/pdb created by the Roslyn C# compiler. This type of debug info is not new, but because of a subtle issue (bug) with the way previous C# compilers wrote these metadata records, other pdb consumers were not reading them.

using System.IO;
using Microsoft.Cci;
using Microsoft.Cci.MetadataReader;

class Program
    static void Main()
        var host = new DefaultWindowsRuntimeHost();
        var reader = new PdbReader(new FileStream("containsdynamiclocals.pdb", FileMode.Open), host);
Unhandled Exception: Microsoft.Cci.Pdb.PdbDebugException: Unknown custom metadata item kind: 5

file attachments

Closed Nov 10, 2014 at 10:01 PM by mikebarnett
Fixed thanks to Tomas!


Kevin_H wrote Jan 21, 2014 at 6:26 PM

adding attachment

kerem wrote Apr 21, 2014 at 11:47 AM

kerem wrote Oct 28, 2014 at 11:13 AM

CodeContractsRosyln project also reproduces this error and there is a workaround explained in Curious Case of Code Contracts and Roslyn