0

This is what I'm doing:

  1. Set C++ project as startup project
  2. Build
  3. Set many break points
  4. press F5

the correct project is started, the breakpoints are shown as valid and loaded (filled red circle), visual studio says "Running" in the title bar, the debug toolbar is activated but the program doesn't stop on the break points.

If I use the attach to process functionality, selecting "Managed (v4.6, v4.5, v4.0) code, Native code", the program does stop on the break points and I can debug correctly.

does any1 have any tips to troubleshoot or solve this?

as a side note (I don't know if the problems are related to each other), my F11 (step into) key also doesn't work, I have tried resetting the visual studio settings but it didn't fix the issue.

[EDITED] If I need to debug code before I get user interaction ready I need to set up something to block the program until I can attach to the process.

  • @duDE that when I press the F5 button on visual studio it doesn't attach visual studio to the application – Robson Dec 11 '17 at 8:49
  • But F5 shall not do it, it means "Run"! The short cut to attach to a process is "Ctrl+Alt+P" or am I wrong? – duDE Dec 11 '17 at 9:32
  • @duDE the default for F5 is Start Debugging, on the other hand CTRL+F5 will do Start Without debugging. – Robson Dec 13 '17 at 9:11
  • So you need first to attach to process with "Ctrl+Alt+P" and then start debugging by clicking "F5". And what is the problem with it? – duDE Dec 13 '17 at 9:17
  • @duDE if I need to debug code before I get user interaction ready I need to set up something to block the program until I can attach to the process – Robson Dec 13 '17 at 9:57
1

Now I hope to understand, what do you need.

Take a look at the method Debugger.Launch Method ():

Launches and attaches a debugger to the process.

And you will need the method Debugger.Break Method ():

Signals a breakpoint to an attached debugger.

So you can use it in your source code directly after entry point like this:

#if DEBUG
                Debugger.Launch();
                Debugger.Break();

                MainForm.Show();
#else
              // nothing to do
#endif

Your program will stop at this point and you can debug!

  • thank you! but this is not what I'm looking for, I want to actually fix the F5 feature. – Robson Dec 15 '17 at 8:54
0

finally fixed it doing the following (I don't know if this is the best way, but it worked for me)

Go to Visual Studio Debug Options (either of the following two ways will open the same page in the options dialog)

  • Debug > Options
  • Tools > Options > Debugging > general

Then in this page be sure to Disable:

  • Enable Just My Code

Then be sure to enable

  • Use Managed Compatiblity Mode
  • Use Native Compatibility Mode

Now go to the Attach to Process Dialog:

  1. Debug > Attach To Process > Attach To > Select
  2. Now select "Managed (v4.6, v4.5, v4.0) code", "Native code" and "Managed Compatibility Code"

Then for each project that you want to debug:

  1. Right click > Properties > Debugging > Debugger Type
  2. Set value to : "Mixed"

Now press F5 and all the managed and unmanaged break points should be active!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.