views:

89

answers:

1

I'm trying to read a PDB file into a C# application. When I call loadDataFromPdb or loadAndValidateDataFromPdb with a file that I know exists, I get an HRESULT of 0x806D0005. Unfortunately, I have no idea what that means. I have the list of possible results [here](http://msdn.microsoft.com/en-us/library/2008hf0e(v=VS.80).aspx) but I'm afraid I can't conclusively determine the problem.

Does anybody know what I'm doing wrong? Or at least a method of checking what that corresponds to?

Exception: System.Runtime.InteropServices.COMException (0x806D0005): Exception from HRESULT: 0x806D0005 at Dia2Lib.DiaSourceClass.loadDataFromPdb(String pdbPath)

Code Sample:

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));
}

Thanks in advance, guys. This problem has been killing me all day.

+2  A: 

Searching for the E_PDB_NOT_FOUND const turned up the source code on google code of dia2.h, which confirmed that 0x806D0005 is 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 ) ,

Note that the signature of the function you're using takes a LPCOLESTR, which is a unicode string. Make sure you're marshaling your string correctly in your interface declaration, ie:

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

The msdn documentation also implies that if the file exists, that error will be returned if it "determined that the file has an invalid format". I doubt this is the actual problem, but if you're generating that pdb file in some non-standard way, the problem could be the pdb file itself.

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. :)

Tanzelax