1
votes

I've just updated a major C++ project from VS2010 to VS2019, and I'm having problems getting Edit and Continue to work like it used to, specifically in relation to the 'Require source files to exactly match the original version' setting (which I will refer to as the 'require match' setting, because it's shorter).

I'm used to running my program, making changes to the source code while it's running, then setting a breakpoint to catch the running application just before the changed code. When the breakpoint is hit, I could hit F5 to rebuild and continue.

In VS2019, it seems that Edit and Continue will not work without the 'require match' setting, but setting breakpoints in existing code cannot be done with 'require match' once any changes are made.

There's a couple of workarounds, but none are ideal. It's possible to turn on "require match" to build and run the program, then after some code changes are made, turn it off to set the breakpoint, then turn it back on again for the rebuild and continue. That's a huge pain. It's possible to use pause and continue to force a rebuild of any edits, but this only works if the code change is complete enough to build. If I want to break to inspect a variable, this doesn't work. Once or twice I did manage to set a breakpoint on changed code, and it automatically went to the stale code, which is acceptable, but I can't get this to happen now. Also, now I have breakpoints that are showing as valid on edited code that has been rebuilt and I know is running, but the breakpoints are not being hit.

Any solutions here, or does Edit and Continue simply not work as well as it used to?

Here's some pictures...

Firstly, while my program is running, I made some change to surfdraw_panels.cpp, then went to add a breakpoint. It shows the following message...

enter image description here

Then loads up a [stale] version of the code, with the breakpoint set in the stale code...

enter image description here

Other times, when I make a change, I get a different result, and it won't allow me to set a breakpoint at all... In VS2010, it was possible to turn off the 'require match' setting and still use 'Edit and continue', but VS2019 will not allow this, even though it is still the recommended 'solution' in the message!

enter image description here

Github project that shows the issue is below. It's a simple MFC app, dialog based, created by the new project wizard in VS2019. There is a single button on the dialog, and some simple code to do something in the button. To recreate the problem, start the app in the debugger, then make a change to OnBnClickedButton1(), and then try to set a breakpoint.

https://github.com/surfdabbler/MFCApplication1

1
It works. Have you tried rebuild all? Are all of the projects set to use the latest toolset?Kenny Ostrom
Yes, and Yes. :)user1961169
What is your VS2019 version? VS2019 16.8? If your VS is not the latest, please update it.Mr Qian
If the new latest vs version has the same behavior, I suggest you could share a reproduce sample from github with us.Mr Qian
Ah, I spoke too soon. I updated from 16.2 to 16.8, and at first I though it was good, but no, it's still there. I'll try making a new project and see if I get the same behaviour.user1961169

1 Answers

1
votes

Not quite understand your specific situation and operation, because there are not some pictures and code to explain the issue in detail.

But this function which I used could break into the changed code during debugging with require match option. You should move your cursor back to the changed code and then Debug the below code step by step. And when you move the cursor back to the changed code, vc++ project will rebuild the changed code automatically and you do not have to stop debugging and restart build.

enter image description here

Update 1

I also faced the same behavior in my side. And since we could not handle the issue here any more, I reported the issue on our DC Forum.

You can vote it and add any comments if I did not describe the issue in detail so that it will get more Microsoft's attention. And I hope the Team will give you a satisfactory reply.