您好,我正在尝试从pdb文件中读取数据
我遵循了How do I use the MS DIA SDK from C#?中的步骤并生成了程序集
问题是:在MS文件上调用dataSource.loadDataFromPdb时,会抛出ComException(HRESULT: 0x806D000C)
我试过使用dumpbin.exe /headers,但失败了,出现“未知格式”。
在自生成的pdb上使用.loadDataFromPdb和dumpbin可以正常工作
IDiaDataSource dataSource = new DiaSourceClass();
//dataSource.loadDataFromPdb(@"D:\Symbols\System.Data.Entity.pdb"); // Fails
dataSource.loadDataFromPdb(@"D:\Symbols\myassembly.pdb"); // Success
IDiaSession session;
dataSource.openSession(out session);
var guid = session.globalScope.guid.ToString();
有没有其他方法可以打开MS pdb文件,特别是提取GUID
发布于 2014-12-02 09:53:51
基于info here的一些数学运算表明,0x806D000C对应于E_PDB_FORMAT which MSDN has a description of:“尝试访问具有过时格式的文件。”
基于此,我不得不问(是的,可能会晚一点)……您还记得您尝试使用哪个版本的Visual Studio & DIA进行此操作吗?对于Microsoft发送的那些PDB,PDB格式可能已更改,因此您的工具可能不是最新的。
发布于 2014-06-18 05:40:31
可以使用如下所示的BinaryReader从.pdb文件中读取GUID值。关键是获取偏移量:
var fileName = @"c:\temp\StructureMap.pdb";
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binReader = new BinaryReader(fs))
{
// This is where the GUID for the .pdb file is stored
fs.Position = 0x00000a0c;
//starts at 0xa0c but is pieced together up to 0xa1b
byte[] guidBytes = binReader.ReadBytes(16);
Guid pdbGuid = new Guid(guidBytes);
Debug.WriteLine(pdbGuid.ToString());
}
}
要从.dll或.exe获取值,需要做更多的工作:)
https://stackoverflow.com/questions/18374023
复制相似问题