Search code examples
c++dllvisual-studio-2015pdb-fileshotswap

How to force Visual Studio 2015 to unlock .PDB file after FreeLibrary call?


After loading a DLL library using LoadLibrary("file.dll") visual studio also opens and locks file.pdb.

The problem is - the file.pdb is kept locked even after calling FreeLibrary(...).

It is necessary to recompile file.dll and reload it once again (externally, outside of MSVS, using CL.exe), but the compilation fails because file.pdb is still locked.

How to make Visual Studio 2015 release the file lock?


Solution

  • Coincidentally I've stumbled upon a solution to this:

    Go to Tools -> Options then Debugging -> General, then turn on Use Native Compatibility Mode.

    This fixes the issue (e.g. .pdb file is unlocked after unloading .dll now).

    I've no idea why, as I can't find the documentation for Use Native Compatibility Mode.