3

我正在尝试将 PDB 文件读入 C# 应用程序。当我调用loadDataFromPdbloadAndValidateDataFromPdb使用我知道存在的文件时,我得到一个 0x806D0005 的 HRESULT。不幸的是,我不知道这意味着什么。我有可能的结果列表 [这里]( http://msdn.microsoft.com/en-us/library/2008hf0e(v=VS.80).aspx)但恐怕我无法最终确定问题。

有人知道我做错了什么吗?或者至少是一种检查对应内容的方法?

异常:System.Runtime.InteropServices.COMException (0x806D0005):HRESULT 异常:Dia2Lib.DiaSourceClass.loadDataFromPdb (String pdbPath) 处的 0x806D0005

代码示例:

public static void LoadSymbolsForModule(uint baseAddress, uint size, uint timeStamp, DM_PDB_SIGNATURE signature)
{
    IDiaDataSource m_source = new DiaSourceClass();
    //m_source.loadAndValidateDataFromPdb(signature.path, ref signature.guid, 0, signature.age);
    m_source.loadDataFromPdb(signature.path);
    IDiaSession m_session;
    m_source.openSession(out m_session);
    m_session.loadAddress = baseAddress;
    modules.Add(new Module(baseAddress, size, m_session));
}

提前谢谢各位。这个问题一直让我死了一天。

4

1 回答 1

2

搜索 E_PDB_NOT_FOUND const 在 dia2.h 的谷歌代码上找到了源代码确认 0x806D0005 是 E_PDB_NOT_FOUND。

E_PDB_OK            = ( HRESULT  )(( ( ( ( unsigned long  )1 << 31 )  | ( ( unsigned long  )( LONG  )0x6d << 16 )  )  | ( unsigned long  )1 ) ),
E_PDB_USAGE         = ( E_PDB_OK + 1 ) ,
E_PDB_OUT_OF_MEMORY = ( E_PDB_USAGE + 1 ) ,
E_PDB_FILE_SYSTEM   = ( E_PDB_OUT_OF_MEMORY + 1 ) ,
E_PDB_NOT_FOUND     = ( E_PDB_FILE_SYSTEM + 1 ) ,

请注意,您正在使用的函数的签名采用LPCOLESTRunicode 字符串。确保您在接口声明中正确编组字符串,即:

Int32 loadDataFromPdb ( [MarshalAs(UnmanagedType.LPWStr)] string pdbPath );

msdn 文档还暗示,如果文件存在,如果它“确定文件具有无效格式”,则会返回该错误。我怀疑这是实际问题,但如果您以某种非标准方式生成该 pdb 文件,则问题可能出在 pdb 文件本身。

Searching for the hresult and E_PDB_NOT_FOUND found someone that encountered the same problem. It seemed that their problem was due to resource consumption, ie too many pdbs being loaded or not being released properly. Other search results for that hresult and that error name seem to support the possibility that this error is being thrown for other failures to load the pdb, such as pdbs being too large.

Hopefully this helps a bit. :)

于 2010-05-20T01:59:18.347 回答