PEReader.TryOpenAssociatedPortablePdb Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Opens a Portable PDB associated with this PE image.
public:
bool TryOpenAssociatedPortablePdb(System::String ^ peImagePath, Func<System::String ^, System::IO::Stream ^> ^ pdbFileStreamProvider, [Runtime::InteropServices::Out] System::Reflection::Metadata::MetadataReaderProvider ^ % pdbReaderProvider, [Runtime::InteropServices::Out] System::String ^ % pdbPath);
public bool TryOpenAssociatedPortablePdb (string peImagePath, Func<string,System.IO.Stream?> pdbFileStreamProvider, out System.Reflection.Metadata.MetadataReaderProvider? pdbReaderProvider, out string? pdbPath);
public bool TryOpenAssociatedPortablePdb (string peImagePath, Func<string,System.IO.Stream> pdbFileStreamProvider, out System.Reflection.Metadata.MetadataReaderProvider pdbReaderProvider, out string pdbPath);
member this.TryOpenAssociatedPortablePdb : string * Func<string, System.IO.Stream> * MetadataReaderProvider * string -> bool
Public Function TryOpenAssociatedPortablePdb (peImagePath As String, pdbFileStreamProvider As Func(Of String, Stream), ByRef pdbReaderProvider As MetadataReaderProvider, ByRef pdbPath As String) As Boolean
Parameters
- peImagePath
- String
The path to the PE image. The path is used to locate the PDB file located in the directory containing the PE file.
If specified, called to open a Stream for a given file path. The provider is expected to either return a readable and seekable Stream, or null
if the target file doesn't exist or should be ignored for some reason. The provider should throw IOException if it fails to open the file due to an unexpected IO error.
- pdbReaderProvider
- MetadataReaderProvider
If successful, a new instance of MetadataReaderProvider to be used to read the Portable PDB.
- pdbPath
- String
If successful and the PDB is found in a file, the path to the file, or null
if the PDB is embedded in the PE image itself.
Returns
true
if the PE image has a PDB associated with it and the PDB has been successfully opened; otherwise, false
.
Exceptions
peImagePath
or pdbFileStreamProvider
is null
.
The stream returned from pdbFileStreamProvider
doesn't support read and seek operations.
No matching PDB file was found due to an error: The PE image or the PDB is invalid.
No matching PDB file was found due to an error: An IO error occurred while reading the PE image or the PDB.
Remarks
This method implements a simple PDB file lookup based on the content of the PE image Debug Directory. A more sophisticated tool might need to follow up with additional lookup on search paths or a symbol server.
The method looks the PDB up in the following order:
- Checks for a matching PDB file of the name found in the CodeView entry in the directory containing the PE file (the directory of
peImagePath
). - Checks for a PDB embedded in the PE image itself.
The first PDB that matches the information specified in the Debug Directory is returned.