views:

256

answers:

2

I set a breakpoint in my code in Visual-C++, but when I run, I see the error mentioned in the title.

I know this question has been asked before on Stack Overflow (http://stackoverflow.com/questions/657470/breakpoints-cannot-be-set-and-have-been-disabled-problem), but none of the answers there fully explained the problem I'm seeing. The closest I can see is something about the linker, but I don't understand that - so if someone could explain in more detail that would be great.

In my case, I have 2 projects in Visual C++ - the production dsw, and the test code dsw. I have loaded and rebuilt both dsws in debug mode. I want a breakpoint in the production code, which is run via the test scripts. My issue is I get the error message when I run the test code, because the break point is in the production code, which isn't loaded up when the test starts.

Near the beginning of the test script there is a mytest_initialize() command. I imagine this goes off and loads up the production dll. Once this line has executed, I can put the breakpoint in my production code and run until I hit it. But it's quite annoying to have to run to this line, set the breakpoint and continue every time I want to run the test.

So I think the problem is Visual C++ doesn't realise the two projects are related. Is this a linker issue? What does the linker do and what settings should I change to make this work?

Thanks in advance. Apologies if instead I should be appending this question to the existing one, this is my first post so not quite sure how this should work.

[Update 1] I think Chris O has identified the problem. I'll add a further update if I'm able to work out how to use the project settings to make this work.

A: 

It sounds like you are using VC6, since you mention dsw files. I think that is as good as it gets in VC6, you have to manually add the breakpoint after your module is loaded from LoadLibrary. Actually, there might be a project debug setting, so you can specify which DLLs to load when debugging your project, that will keep your breakpoints enabled when hitting F5.

You can also try attaching the debugger after you know the mytest_initialize() has been called, that might keep your breakpoints enabled.

Chris O
You're correct, I am running VC6.I should also clarify I'm running the test scripts direct from VC6, so I guess the debugger gets attached right away.I've had a quick dig in the Project Settings->Debug dialog. It looks like I should be able to fix this up here. If I select my test project in the left window, I'm then able to add the production DLL under Category: Additional DLLs. Unfortunately this doesn't make any difference! I'll play with this a bit more - it looks like this *should* be a way to fix the problem.
sam
A: 

Hi.

I had this issue sometimes, but always pass this with some code replacement actions.

Here is some guy post, how he had fixed it.

Hope it helps.

mosg