0
votes

If I change something in a code, my breakpoint no longer work. It's as if the visual studio compiles the old source code.

The program runs as if the old code/before change works.

enter image description here

Cleaning and recompiling works, however, it's kind of boring. Everytime I change a code I should be able to get a new .exe

I read a similar question "The breakpoint will not currently be hit. The source code is different from the original version." What does this mean?

Notice the question is not entirely similar. Basically the questioner there ask how to fix the problem. I can fix the problem. Just clean the project and run it again. My question is why is this keep happening and how to stop it.

One solution is to ensure that if projects don't compile just run previous iteration. I am very sure that is not the problem. That's because my changes should make the project compile anyway. Also, this screenshot can show that's not an issue.

enter image description here

A good answer would explain to me how this compile really works. Why visual studio compile the old code? Can't visual studio see that I have made changes? In fact, it used to work properly before. Should I reset all visual studio settings? How? Is the problem in my visual studio settings or on the vbproj file?

Is there a way that the encoding of the text files (.vb files) are not proper. I think this starts happening after I edit one of the file outside of visual studio once. I am not sure.

2
"On Run, when projects are out of date", you have "never build". Change it to "Always build".Joe Sewell
"Compile old code" is not the likely explanation, much more likely is "old .exe file" or "old .pdb file". File system problems have many possible explanations, on the top of that list is always anti-malware. The "crap, build again, hey now it works" scenario is giving it more time to perform a scan. Make an exclusion, if that works then get rid of it post-haste.Hans Passant
@JoeSewell can you turn that into an answer. I am not sure if this is the issue, but resetting visual studio settings fixed my issue. I have no idea why that option could change. It seems that with that option, if I change a code, then the project is out of date. Instead of rebuilding, visual studio opt not to build a new project and hence I got this problem. That seems to make sense there. If that's the case can you turn that into an answeruser4951
I think that's the issue. After resetting the vb.net setting, that setting changed. Yap. Please turn that into an answer or I'll just answer this my self.user4951

2 Answers

0
votes

Per @JoeSewell comment.

"On Run, when projects are out of date", you have "never build". Change it to "Always build"

I believe that's the culprit.

I can't know for sure. However, I fixed the whole problem by just resetting visual studio settings.

There are reasons that the "when projects are out of date" is the culprit.

It seems that with that option, if I change a code, then the project is out of date. Instead of rebuilding, visual studio opt not to build a new project and hence I got this problem.

0
votes

I found I was referencing a dll in the project (from a different project) that had since been updated but not in this project's bin folder. I sorted it by referencing the second project rather than the dll so every time it is rebuilt it will have the latest dll in there.