0

I'm getting started with the DIA SDK and have the following simple code:

#define PRINTIFHRIS(x) if (hr == x) printf(#x "\n");

int main()
{
    HRESULT hr;
    IDiaDataSource *ds = NULL;
    wchar_t cwd[300];

    GetCurrentDirectory(300, cwd);

    printf("CWD: %S\n", cwd);

    hr = CoInitialize(NULL);
    assert(SUCCEEDED(hr));

    hr = CoCreateInstance(
        CLSID_DiaSource,
        NULL,
        CLSCTX_INPROC_SERVER,
        __uuidof(IDiaDataSource),
        (void**)&ds
    );
    assert(SUCCEEDED(hr));

    hr = ds->loadDataForExe(L"readpdb.exe", NULL, NULL);
    PRINTIFHRIS(E_PDB_NOT_FOUND);
    PRINTIFHRIS(E_PDB_FORMAT);
    PRINTIFHRIS(E_PDB_INVALID_SIG);
    PRINTIFHRIS(E_PDB_INVALID_AGE);
    PRINTIFHRIS(E_INVALIDARG);
    PRINTIFHRIS(E_UNEXPECTED);
    PRINTIFHRIS(S_OK);
    assert(SUCCEEDED(hr));

    return 0;
}

If I start this from the Visual Studio IDE, it assert fails with E_PDB_NOT_FOUND, even if I start it without debugging. But if I start the very same program outside the IDE it works fine and returns S_OK. First I thought it's a working directory issue, so I put printf at the beginning to see if that's the problem, but it isn't the problem. The working directory is the same and PDB is there.

Does Visual Studio do something that affect the DIA SDK's behavior? I don't see anything in the documentation.

Calmarius
  • 18,570
  • 18
  • 110
  • 157

1 Answers1

1

maybe you can check the current directory difference between the IDE and your outside run, because loadDataForExe will search pdb file in current directory by default.

oppo
  • 169
  • 8
  • This problem is also related with the symsrv.dll, you may try copy the file of the right version to the runtime directory. – oppo Jul 15 '15 at 06:58