Skip to content

F# compiler should set major version of Embedded PDB #6832

@eerhardt

Description

@eerhardt

When using DebugType=embedded with F# projects, and then trying to load the resulting library with PEReader, I am getting an exception. This is because PEReader is validating that the version is at least the expected version:

https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.EmbeddedPortablePdb.cs#L52-L70

Repro steps

Provide the steps required to reproduce the problem:

  1. Set <DebugType>embedded</DebugType> in a .NET Standard .fsproj
  2. Build
  3. Pass the built .dll into the following code:
string filename = ...;
using (var fileStream = File.OpenRead(filename))
{
    PEReader reader = new PEReader(fileStream);

    foreach (var entry in reader.ReadDebugDirectory())
    {
        if (entry.Type == DebugDirectoryEntryType.EmbeddedPortablePdb)
        {
            reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry);
        }
    }
}

Expected behavior

PEReader shouldn't throw on the assembly.

Actual behavior

System.BadImageFormatException
  HResult=0x8007000B
  Message=Unsupported format version: 0.0
  Source=System.Reflection.Metadata
  StackTrace:
   at System.Reflection.PortableExecutable.PEReader.ValidateEmbeddedPortablePdbVersion(DebugDirectoryEntry entry) in F:\workspace\_work\1\s\src\System.Reflection.Metadata\src\System\Reflection\PortableExecutable\PEReader.EmbeddedPortablePdb.cs:line 62

Known workarounds

Don't use embedded PDBs.

cc @KevinRansom @tmat

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions