Reputation: 2631
I have a Visual C++ solution which includes a StartUp project and many DLL projects which are dynamically loaded and unloaded by the StartUp project. I'd like to rebuild a DLL project without stopping the current debugging session. However trying this will prompt me with the "Do you want to stop debugging?" popup.
Manually running msbuild on the project will fail with:
"D:\MySolution\MyDLLProject\dllproject.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1201: error writing to program database 'D:\MySolution\compiled\DebugDB\MyDLLProject\Debug\dllproject.pdb'; check for insufficient disk space, invalid path, or insufficient privilege [D:\MySolution\MyDLLProject\dllproject.vcxproj]
Is there a way to circumvent this?
Upvotes: 2
Views: 2120
Reputation: 431
There´s built in mechanism inside VS to alow this to happen.
(Just tested with a C# MVC project)
Instead to compile with (F5), use (Ctrl + F5). This will compile your solution with no debugger attached to the browser.
Do not close the bowser tab and Get back to Visual studio. Change anything inside a controller or a class. You will see that Visual Studio works smooth like when the solution it´s stop.
Now, press (Ctrl + Shft + B) to call the build mechanism. This will generate all new dlls
Switch to the browser again and refresh the page (F5 or Ctrl + r)
This is a time saver!
In summary
Upvotes: 1
Reputation: 1721
What you need to make sure is that the pdb file which gets generated by your new build of the dll is not the same as with the last build.
Using the command line to build the dlls you could invoke the compiler/linker with a command line switch -PDB:>>PDBFILENAME_%random%.pdb<<
This will create a pdb file which is different everytime you recompile.
Example: cl main.cpp -LD /link -PDB:test_%random%.pdb
Upvotes: 2
Reputation: 16705
The reason of the error is that the pdb
files are currently in use by your MSVC-debugger. While building your project in debug mode this files are need to be overwritten but this is impossible since you can't delete the file that is currently in use.
A program database (PDB) file holds debugging and project state information that allows incremental linking of a Debug configuration of your program. It also stores the debug information.
So if you'll build your project without pdb
files you'll be able to build it while debugging. But in this case, since your pdb-files would be outdated you are unable to debug your application. That means, that to rebuild your project and be able to debug it after you ought to stop your debugger session. Or, as a doubtful solution, you may build it into another directory to avoid pdb-file write conflicts.
Upvotes: 2