I just made a new Console Aplication project in Visual Studio C++. I changed the setup to see the Console when compile&run ( CTRL + F5 ).
However, when it comes to running into debugging mode ( F5 ), the program is ending even if i do have breakpoints in several places.
The red circles turn to white and have an exclamation mark during those 2 seconds while it tries to debugg.
Anyone knows how to fix it ?
(1) Please make sure that your app is in debug mode(not release mode).
(2) Please enable the options like the following screen shot.
Reference:
https://connect.microsoft.com/VisualStudio/feedback/details/797465/visual-c-debugger-does-not-stop-on-breakpoint
There are several things you can check.
First of all assure that the code where the breakpoint is set is reachable. Put it on the entry point of your application.
There is a possibility that the debug symbols where somehow messed up. Hence, try cleaning/rebuilding the project (you can try to delete the bin/build dirs manually).
You could also check under Build->Configuration Manager whether the "Debug" for solution configuration actually makes your project be executed in Debug mode.
Related
First off, i haven't been coding or using Visual studio for super long so please explain in details so i can follow. Thanks!
Every time i try to run any code i get the message "ops" in the debug window. I disabled my antivirus(windows defender) and reinstalled a bunch of times. I get the same issue using Visual studio 2019. Anyone have ideas ?
I tried a bunch of different codes and even the default hello world that the Windows Console Application gives you isn't running.
Please check for the existence of one of the following registry keys.
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
If they exist and are not expected, please remove. They may be created by malware, so you may need to use an antivirus product to remove the unwanted software.
Step 1: Add a breakpoint at the top of your program.
Step 2: Enlarge the tiny console window to a normal size.
Step 3: Click "Continue" on the debugger.
Step 4: "ops" turns into "To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops."
My Visualstudio 2017 Breakpoints are invisible, which means they appear in the submenu.
My application stops by hitting each breakpoint correctly.
I'm able to set and delete Brakpoints via the sidebar next to the line bar.
Breakpoints can be controlled by rightclick them and the submenü will open
BUT:
They wont appear. Setting a breakpoint in the bar only left a grey bar behind as there is no breakpoint.
So far I tried:
Reinstall vs 2017 7 times
Deinstalling all plugins and similar stuff (visual assist, Qt etc.)
Delete every project
Delete every %appdata% stuff
Delete registry data for vs
Tryed (I hope) everything in Debug config and vs settings
Installed it on my laptop using also intel Windows 10 etc. (there it workes, but I still need it on my pc)
Solution:
(System: Win-10)
(VisualStudioversion: 17/19)
Check if there is a breakpoint.png on your computer (if this is missing, this solution wont work). (Search in Windows explorer and enable to see all file and search trough everything filename, file etc. [enable this in the settings])
Create Win10 .iso with the offered tool from Microsoft here and store it on the desktop.
Execute this .iso and press install Windows. [Dont forget to cross the right checkbox to keep your data and just replace all your windows files]
!Some settings will be gone after new installation as they inherited by the system! (but most things will stay)
After finishing the (re)installation just start vs 17/19 and the Breakpoint should work now or better should be visible breakpoints. :D
Note: I tried a lot of things including a huge amount of testing, checking etc.. This solution should work, but there is the possibility, that I fixed the issue with some other test or stuff I've done. Though there is no guarantee that this will work, but if it doesn't work, just leave a comment and I can try to remember what I've done along my solution process.
I found a thread of another user on another website with the same problem except he is using Fortran while I am using C++:
https://software.intel.com/en-us/forums/topic/508718
In fact, I can cite her/him:
The problem:
My problem is that in the debug mode the program algorithm works fine except it does not show the values of the variables.
I tried the watch window and also moving mouse over the variable but neither of them works.
I tried very simple codes like Hello World and just defined an integer but the program is unable to show the value of the variable in debug mode.
From time to time the debug mode works correctly. Sometimes I have to restart the debugger 10 times and then it works for 1 time. It does not matter whether I add or remove breakpoints.
My setup:
Windows 7 64 Bit
Visual Studio Ultimate 2013 (from MSDNAA, all original stuff) Version 12.0.30501.00 Update 2.
I have another notebook with Windows 7 64 Bit and the same Visual Studio Version installed -> same problem!
I have the same problem once in a while and the following steps help me solving it:
Make sure optimizations are deactivated in your Debug build. If they are enabled you compiler removes stack frames, puts variable values into cpu registers or inlines whole functions. The debugger does not like optimizations.
Make sure you use a Debug Runtime Library (check 'Runtime Library' in 'Code generation' and select Multithreaded-Debug or Multithreaded-Debug-DLL)
Rebuild your application (right click Project -> "Rebuild"). Sometimes there are problems which can be solved by a rebuild (i.e. when you update source files from repository which are older then your binaries but newer then the source you built the binaries from; or when you update your compiler or libraries and only parts of your application are rebuild).
Disable Minimal Rebuild in 'code generation' option page. It may mess up you program database.
If everything fails you may try to create a clean new project with default settings and add all your existing .cpp/.h files. This way you make sure your settings are not messed up.
If you are using global variables defined within a namespace you always have to enter the namespace into the watch window (i.e. a variable 'x' defined in namespace 'Y' must be watched as 'Y::x')
Use getchar(); at the end of the program or at the end of a cout statement. In my experience, I had to use getchar(); multiple times to show the variables and the solution. Try it!
I'm having a problem in visual c++ 2010 express, when I try to run my code it runs well, but when I close it, it runs again. So I think the problem was in my code, so I try a very basic code like this.
#include <iostream>
int main()
{
std::cout << "test" << std::endl;
return 0;
}
then I try to reset the vc++ settings, but still the .exe is runnning 2x even in the debugger. Then I try to reinstall but still the same problem. I try to import my .exe to other machine to see if it will run 2x, and yes, it runs again after I close it. So I hope someone here can help me fix this problem.
It's weird but it's possible.
There is someone who asked before on how to do it: Run multiple instances with one click in Visual Studio (what you are get rid of is sometimes what others desire to have :)). The following notes are borrowed from there. So you can check your visual studio setting whether the followings are set or not. Probably you got the following set. Hope it helps.
suppose your current project is A, and it's output is c:\bin\my.exe
add an empty project to the solution for A, call it 'Dummy'
under Dummy's Project Properties->Debugging set the Command to point c:\bin\my.exe
under Solution Properties->Configuration Manager, uncheck all builds of the Dummy project so VS won't try to build it (building an empty project fails)
under Solution Properties->Startup Project, select Multiple Startup Projects and set the Action for both A and Dummy to Start
now hit F5 and your exe will be launched twice, each under a seperate debugging instance. (as you will be able to see in the Debug->View->Processes window)
If I create a new win32 C++ project in VS2008 I can use Edit & Continue with it just fine, but with this legacy project I'm working with my attempts to use / enable it have failed.
Here are things I've checked:
Tools -> Options -> Debugging -> Edit and Continue -> Enable Edit and Continue is ON.
Debug Information Format: Program Database (/Zi)
Code Generation -> Enable Function-Level Linking: Yes (/Gy)
Looked for a corrupt .ILK file. I can't find any .ILK files - are they still used in 2008?
But when I step into the program, change the next line, and step again, I get:
"This source file has changed. It no longer matches..."
rather than
"Would you like Edit & Continue to apply your code changes."
What's wrong with this project that E&C doesn't work?
I assume you have debugging symbols/etc and the legacy C++ application had been compiled with this support...
If not, then you will run into the problem that the code was not 'instrumented' to allow for injection of alternate code.
I would suspect that the changes in output code format would make VC++ 2008 incompatible... as I doubt Microsoft added such backwards compatibility in (until VS 2008, I think they even made it hard to use older versions of .Net without using the specific VS)
This messagebox
This source file has changed. It no longer matches the version of the file used to build the application being debugged.
seems only to be appearing when I made a code change on the exact line where the breakpoint is.
I've found that I can just click the OK button. And when I then press F10 to actually execute the line that has changed, "Edit and Continue" kicks in and recompiles the code.
After that, the breakpoint is disabled though (it shows a yellow triangle with an exclamation mark):
To re-enable it, you can just right-click the breakpoint and choose "Location...":
which brings you to this dialog:
:
where you need to check the "Allow the source code to be different from the original version" checkbox. Click OK and your breakpoint will be enabled again.