7

With VS2013 Pro I am not able to use "Edit and Continue" when debugging an MFC program. I created a new MFC project to test.

OS is Windows 7 64-bit and I'm running Visual Studio 2013 12.0.30110.00 Update1.

Under Tools->Options->Debugging->Edit and Continue I have Enable Edit and Continue checked. I have unchecked it and checked it, but whenever I modify the code while debugging I get the following message:

The source file has changed. It no longer matches the version of the file used to build the application being debugged.

Basically I haven't changed any settings except for the tab sizes and I've set the keyboard mapping scheme to VC6.

What setting am I missing to enable edit and continue?

Nerdroid
  • 13,398
  • 5
  • 58
  • 69
MaxiFlash
  • 103
  • 1
  • 2
  • 9
  • Someone really needs to write an edit and continue wizard here! This is a case of 'property hell'! :) – JCx Jun 14 '15 at 14:26

8 Answers8

8

Edit and Continue is disabled for native code by default. To enable:

  1. On the Tools menu, click Options.
  2. In the Options dialog box, open the Debugging node, and select the Edit and Continue category.
  3. In the Native-only options group, select Enable native Edit and Continue

Edit: Steps to test native Edit and Continue is working:

  1. Start VS 2013
  2. Create a new MFC project:
    • FILE->New Project->MFC Application->OK.
    • Select Finish on the MFC Application Wizard.
  3. Build and start debugging:
    • BUILD->Build Solution
    • DEBUG->Start Debugging
  4. Break into the program:
    • DEBUG->Break all
  5. Make a code change:
    • Open OutputWnd.cpp and find COutputWnd::OnSize (Line 80)
    • Insert this line at the start of the function: cx = cx / 2;
  6. Continue execution:
    • DEBUG->Continue
  7. Resize the application window to see the effect of the code change on the Output pane at the bottom. Its width should be half the required size.
CarlJohnson
  • 541
  • 4
  • 11
  • 1
    Thank you for these settings. However, now I get the following dialog: Edits were made to the code which cannot be applied while debugging. Click Restart to stop debugging, rebuild the code, and restart debugging. Click Edit to make changes to the code. Click Ignore to continue without applying the edits. Note: All I want to do is to be able to edit-and-contine an MFC program. – MaxiFlash Apr 22 '14 at 08:24
  • I've added some test steps to help find what the problem is. – CarlJohnson Apr 22 '14 at 13:01
  • WOW! You are right!! BUT, can you explain why my test vanilla MFC dialog which I created BEFORE I enabled the native-only options still does not work? I also have an MFC project with about 60K lines where I would love to get "Edit and Continue" working. I'm completely stumped. All the same, thank you so much for proving that "edit-and-continue" can work. – MaxiFlash Apr 22 '14 at 14:31
  • See my post below **Problem found - now I need a solution** – MaxiFlash Apr 22 '14 at 16:57
3

Edit and continue is also a Setting for each project.

  1. It must be set in the compiler options under C++ -> General -> Debug Information Format: "Program Database for Edit And Continue (/ZI)"
  2. Also the linker settings must be changed. The linker has to use incremental linking. Linker -> General -> Enable Incremental Linking = Yes or (for VC 2012 users) C++ -> All Options -> Enable Function-Level Linking = Yes (/Gy)

For more information read the MSDN.

Robert
  • 1,357
  • 15
  • 26
xMRi
  • 14,982
  • 3
  • 26
  • 59
  • Thanks for your info. Unfortunately, both project settings are already set by default. I checked your link to MSDN and wanted to apply the changes explicitly but I don't have an "Apply Code Changes" in the debug menu. What does exist under the debug menu is 'Options and Settings'. There, under "Debugging->Edit and Continue", "Enable Edit and Continue" is checked but everything is grayed-out. – MaxiFlash Mar 12 '14 at 12:34
  • Do use use some settings that make edit & continue impossible? Look into the link... – xMRi Mar 12 '14 at 12:59
  • My test, using standard settings. I create a new MFC project. A dialog and statically linked. Then I compile. Then I set a breakpoint in OnInitDialog(). Then I debug run up to the breakpoint. I add a line somewhere below the breakpoint, int iTest = 6; then I continue. NO LUCK! – MaxiFlash Mar 12 '14 at 13:08
1

I did all steps described above, but nothing helps (thanks all for it).

My solution was:

Project -> Properties -> Linker -> Advanced:

set

"Image Has Safe exception handlers" = NO(/SAFESEH:NO)

Apply, Ok, and Rebuild project.

Hope it helps.

Irvin Dominin
  • 30,819
  • 9
  • 77
  • 111
JEX725
  • 61
  • 5
  • Despite all the useful tips, I still can't get Edit-And-Continue to work when I don't use pre-compiled headers and use static linking. For testing I start a new project, then under Project->Properties->Configuration Properties->C/C++->Precompiled Headers->Precompiled Header = Not Using Precompiled Headers. Also Project->Properties->Configuration Properties->General->Use of MFC=Use MFC in Static Library. I have tried adding the other flags mentioned on this page, but no luck. – MaxiFlash Feb 03 '15 at 08:42
1

The last hint helped, but we had to

set "Image Has Safe exception handlers" = NO(/SAFESEH:NO)

in all projects of our solution!

1

For what it's worth I've been pulling my hair out on this one as well. I finally got edit and continue working by changing the following setting:

Project > Properties > Linker > All Options > "image has safe exception handlers".

It was set to No (/SAFESEH:NO). I went in and deleted it. I didn't set it to YES, or NO. I simply kept it blank. I would love to know what it means to be blank. But edit and continue is now working for me. Maybe it will help for you.

mitch
  • 396
  • 1
  • 7
  • 14
1

A project with a "Release Configuration" will disable Edit and Continue.

To change this

  1. Open "Configuration Manager"
  2. Change Configuration for the project from Release to Debug
  3. Rebuild and debug project
bhattamer
  • 121
  • 5
0

Edit and Continue will also not work if your project's Platform Toolset is set to Visual Studio 2012 (v110), instead of the usual Visual Studio 2013 (v120).

This setting is in Project > Configuration Properties > General > Platform Toolset.

Nanki
  • 798
  • 7
  • 9
  • Thanks for this additional info. My platform toolset is Visual Studio 2013 (v120_xp). I HAVE to support XP. – MaxiFlash Sep 10 '14 at 12:09
0

The solution of this problem is on the Microsoft Documentation...

If IntelliTrace is enabled and you collect both IntelliTrace events and call information, Edit and Continue is disabled.

On Visual studios' menu go on Tools>>options - Select "IntelliTrace" tab and let IntelliTrace events only checked.. Save, restart the visual studio and.......

Your Edit and Continue will work again!

Thiago Araújo
  • 800
  • 9
  • 8
  • The "IntelliTrace" tab is missing! Right after "Debugging", where "IntelliTrace" should be, I have "Performance Tools". I have expanded all the tabs but "IntelliTrace" is nowhere to be found. I'm Using Visual Studio 2013 Pro version 12.0.30626.00 update 3 RC. Help!! – MaxiFlash Nov 14 '14 at 08:37