Open sandboxFocusImprove this doc

PS0134: Symbol File Cannot Be Read

Severity Warning
Reported by PostSharp
Message Cannot read the symbol file "<Path>": <Reason>

Cause

When PostSharp reads an assembly, it also reads its debugging symbols, so that the woven assembly keeps the sequence points and the names of local variables that the debugger needs. PostSharp looks for a PDB file next to the assembly, with the same name and the .pdb extension, and otherwise for a portable PDB embedded in the assembly.

PostSharp reports PS0134 when the PDB file exists but cannot be read:

  • The file is in the Windows PDB format, for example written by an older compiler or by a tool on Windows, and the build runs on Linux or macOS: only Windows can read this format. <Reason> is then the Windows PDB format can be read on Windows only.
  • The file is corrupted, truncated, locked by another process, or does not match the format that PostSharp expects. <Reason> is the message of the exception that PostSharp caught.

<Path> is the full path of the PDB file. The message has no location. PostSharp continues without the symbols of this assembly, so the woven assembly can be harder to debug.

This message depends on the files of the build, so no example can show it.

Resolution

  • Use portable PDB files, which every platform can read: set the DebugType MSBuild property to portable or embedded in the project file. SDK-style projects use portable by default.

    <PropertyGroup>
      <DebugType>portable</DebugType>
    </PropertyGroup>
    
  • When <Reason> reports a corrupted or locked file, rebuild the project after deleting its obj and bin directories, and check that no other process, such as an antivirus or a file synchronization tool, holds the file.

  • When the PDB file comes from a tool that rewrites the assembly before PostSharp, check that this tool writes a valid PDB file, or run it after PostSharp.

See Also

Other Resources

Well-Known MSBuild Properties
Debugging Run-Time Logic