4

I'm having a weird problem with Visual Studio. Whenever I change my code and build, even though I get the notification that the built was successful (and if any, it also shows errors in code and doesn't build) the executable is actually the previous build. This is getting really annoying and frustrating.

If I put a breakpoint on the new lines, the breakpoint gets disabled and it says

The breakpoint will not currently be hit. No executable code is associated with this line. Possible causes include: preprocessor directive or compiler/linker optimization

If I put a breakpoint on old lines of code, it stops processing but shows me this message

The source is different from when the module was built. Would you like the debugger to use it anyway?

I never had this problem before and the source code in on my laptop's hard drive. It saves right away. The only way to get around this to Clean the entire solution manually every time, instead of basically pressing F5.

2
  • 1
    What exactly gets built? Is it the object files but not the executable for example? If so then check the time stamps on source, object, and executable before and after a build and let us know what they are. Also, what are they after a clean build? Commented Oct 29, 2011 at 8:24
  • Can you verify if you haven't opened a single source file multiple times? Commented Oct 29, 2011 at 12:52

6 Answers 6

2

Thanks everyone for their suggestions. My mistake was that I defined the classes inside .cpp files, this somehow caused the linker to do weird (caching probably) stuff and link the old objects. I renamed the file to .h and everything's working as expected.

Sign up to request clarification or add additional context in comments.

Comments

0

Perhaps your code is not built, or is built in a way you don't expect.

You might check by inserting a #error foobar preprocessor directive somewhere. If no error shows when building, you know you are in trouble!

But I never used Visual Studio (I'm only using Linux) so I cannot help more.

Comments

0

It might be that you have set main project some other project and building that. make your project that you want to work on as "Main Project " by set main project available in menu bar.

Comments

0

I think you are using source files from another project (ex: if you are using a dll say, my.dll (which was built using some source files say, mycpp.cpp ); in your current project). When you debugged into the file (mycpp.cpp), maybe you modified it.

Hence you need to rebuild the dll (my.dll) first in the project in which you created my.dll . Or Maybe you have opened a instance of mycpp.cpp in a window & debugging in another window. you should rebuild the dll.

If you are not using files from another project, then I cant guess the cause...but still I would recommend using rebuild rather than clean & build.

please clarify your Question a bit. @David expecting a reply from you...

Comments

0

I was looking for an answer to this issue since I was also stuck with it. A colleague of mine just gave me a solution that works. Yes, it seems really stupid, but it did the trick for me.

Our solution has many projects. He told me to select the project that I wish to break into and set it as the startup project (right-click on the project name and pick "Set as startup project"). I was desperate, so I tried. To my amazement, it works.

Since I have this window opened, I thought I'd share it in case someone else is stuck with the problem.

Comments

0

I faced the same problem. But reason was not as yours. Then I just restarted the visual studio and it ran as expected.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.