Thursday, August 20, 2009

C++/CLI: the debugger can't hit any breakpoint

I'm extending a pure C++ solution using C++/CLI one with VS2008: it's a dll that gets invoked by our main program. For debugging purposes, in the same solution I have a separate project that links to the public interface of the DLL. Nice and easy, right? Yes, until I added the /CLR switch to the compiler command line; from that moment on, I was unable to debug the DLL, since VS couldn't reach the breakpoints I set, showing them as hollow circles with the yellow alert sign superimposed and informing me that no source code could be found. The precise error was:

"Breakpoint will not currently be hit. There is no source code available for the current location"

To make a (quite) long story short, the problem was in the settings of the debugger: you have to set the debugger in mixed mode
in the project of the exe calling the dll.




Tuesday, August 18, 2009

Visual Studio 2008 error "C2471: cannot update program database"

Having converted a Visual Studio 2005 C++ solution to Visual Studio 2008, while regenerating it for the first time I got a bunch of "C2471: cannot update program database" (in italian: "C2471: impossibile aggiornare il database di programma") errors. Ouch... At first I tried installing the Microsoft hotfix but for unknown reason the setup refused to work, then I found this blog post by Loren Heiny, where he writes about a workaround he found. Perhaps the solution is even simpler: just restart Visual Studio 2008 and regenerate the project. Why? Oh well, the only hypothesis I could think of is that, immediately after a solution conversion, VC++ 2008 keeps some files opened and is not able to update them.
Have fun!