Issue:
When I started to debug a Com+ project with VC8, I saw many incorrect value in the watch window, and abnormal step through path
For some CString variable:
When I watch them, I can not see the correct value of them. Sometimes I could see <Bad Ptr>, ""(empty) or some garbage strings like "pÏà".
For some int variable:
I even got the value like 2016111848, in the watch window. But in fact, the correct value should be in 0-10
But I could view the correct value of some other CString and int variable.
And, when I go through some methods step by step by click F10, I find something more strange, for example:
1) if (!m_bReadyForQuery)
2) {// not ready to build query
3) return false;
4) }
5) // this will add WHERE for the key field, if applicable
6) if ( !ProcessKeyCriteria(rstWhere) )
7) {
8) return false;
9) }
...
When it runs 1->3->6->8, so strange! It goes to the return line, but it does not return after that line!
Root Reason:
I believe it is caused by the incomplete rebuild of the project.
Solution:
Finally, I fixed this issue by one of the following 2 reasons( I did all of them, and I'm not quite sure which one make things work)
As I have put this mentioned ATL project, says ComA, into a big solution with other ATL projects (totally around 20 projects). And the projects have some dependencies between each other. Another ATL project, says ComB, has dlldata.c set readonly somehow. When I choose to rebuild the whole solution, it always tells me that the dlldata.c can not be opened. But when I build the solution again, the compiler says ok, the error is ignored.
Now I'd like to say the 2 things I did:
1) Change the dlldata.c of ComB to be writable
2) Delete all output of the whole solution, means all dll, ocx, pdb, lib, map files.
Then rebuild the whole solution. This time the debugger starts to work normally.