0

How do I make DIA release its lock on a pdb file?

I load a pdb and create a session as shown below, and it all works fine, I can use the session to get data from the pdb.

When I'm finished with the pdb I release the session and the DiaSource, but DIA still has a lock on the pdb file, I can't delete the pdb file in explorer until my app exits. How do I tell DIA to release the lock on the pdb file?

CoCreateInstance(__uuidof(DiaSource),
    NULL,
    CLSCTX_INPROC_SERVER,
    __uuidof(IDiaDataSource),
    (void**)&mp_DiaSource);

mp_DiaSource->loadAndValidateDataFromPdb(
    (LPCOLESTR)p_wide_filename, &m_Sig, 0, m_Age);

mp_DiaSource->openSession(&mp_Session);

// do stuff with mp_Session here

mp_Session->Release();

mp_DiaSource->Release();

many thanks.

Stewart.

pnuts
  • 58,317
  • 11
  • 87
  • 139

1 Answers1

1

at least for msdia90.dll, it's true that the file handle is not closed after Release(), a possible workaround is, call loadDataFromIStream(), and pass IStream instead of a path to load pdb file, however, I never test whether this really works.

xwlan
  • 554
  • 3
  • 5
  • Yes, you are right. Using `IStream` does help to avoid lock on a pdb file. I used this code for myself: `IStream* pdbFileStream; SHCreateStreamOnFileEx( "filename", STGM_FAILIFTHERE, GENERIC_READ, false, nullptr, &pdbFileStream );` – Dmitriy Zakablukov Jun 10 '16 at 12:56