Why does Visual Studio sometimes not go to my breakpoints? - c#

I have been using Visual Studio 2005 and 2008 and i have noticed that sometimes when i place break point in my code that it does not want to go to the break point. So i restart my PC and then it works again. Its like something get's stuck? Does this only happen to me???
How can i prevent this! It is driving me nuts!!
Thanks in advance!!

Often this is because the code you are looking hasn't been compiled since you placed the breakpoint, so you test code / unit test, is running against an outdated DLL.
This might be what's happening to you.
Check out your build manager, and make sure all the projects are checked.
Edit:
Go to Build->Configuration Manager and make sure the [Build] checkboxes are all checked, that will ensure that every project is compiled when you build the solution (Ctrl+shift+b).

It depends on if you are developing a web application, or if you have late bound code, changes in controls from another project, etc.... One way to track down problems is to look in the Debug - Windows - Modules pane, and see which assembly is actually being used. If you have remoting boundaries to cross, the breakpoint won't become active until the code is executed. If you hover over the breakpoint when it is not coloured in completely and has that question mark, you can also get more information.
Hope that helps.

I had the same problem with VS 2005.
Apparently Visual Studio's setting were corrupted. I reset them from Tools/Import and Export Settings/Reset all settings. It's now breakpointing fine.
Mike

Instead of rebooting your computer try selecting build -> rebuild solution and then running in debug mode. That usually seems to clear out little annoying things like that.

There's a hotfix for various debugger problems in VS 2008 SP1, have you tried that?

Related

No source available for the current location VS 2012

I have a whole series of dll's added into my assembly. However I cannot find a way to get past the problems of requiring the source code - which I do not have. I'm running in debug mode and the project builds and runs fie, but when using F11 to debug from a break point, when going into a method in one of these dll's I end up with this issue and I cannot make is resolve.
I have tried the following:
Switching off address-level debugging
Enable just my code
I really don't know what I should be doing. Any ideas?
Initially I thought that I could use an option in settings and continue to use F11, but it looks like I'll have to use F10 now which works fine. Thanks to #Hans Passant for his comment.

Visual Studio 2012 won't let me debug

I can't seem to be able to debug. When I try to, I don't get any build errors, and the layout changes to debug mode, but the windows never pops up. I have an orange bar at the bottom of VS, which I think is standard, but nothing happens after that. It's not just in the project I'm working on. I have started a new WFA and tried to debug without adding any code and the same thing happens. Anybody have similar issues?
I've encountered this before. Not sure what causes it, but generally it is one of a couple of things to fix it.
make sure you are building in debug and not release
close VS, go to the project's dir and delete the obj and bin directories. Reopen in VS and rebuild.
there is an option under tools - options - build (iirc) that allows for checking if source is same as code file. However, you should see a message in output window if this is the case.
on the project properties in the build (iirc) you can throttle the pdb file from full debug symbols to no pdb at all. If you are not the only person on the project check this setting still has full pdb enabled (low probability this got changed though)
make sure you're on the right platform that you are building to (x64 vs x32)
...lots more, but a starting place...
Addendum as per comment...
So, those messages are good. It is saying there are no problems (but it sounds like you already know that :) ). I would start with the general debug options you mention. Do this on a hello world app. That way you can troubleshoot the lowest common first. Here are my settings. Try to match them and see if that works. For example, I know "ask before deleting breakpoint" is irrelevant, but "break all processes when one process breaks" is important. So, I just added them all to make it easier to troubleshoot.
ALso, make sure you are getting a red dot here like so in your code in visual studio (I've seen instances where VS won't let you put this here):
Right click on the project
Click on the properties.
go to web.
Check the Box for Enable Edit and Continue .
Hope that helps :)
This is an issue with visual studio 2012. It doesn't ALWAYS show up. I've found that if you stop your program during debugging, or if you close the console window, this will almost always trigger.
However, letting it run to completion isn't enough either, sometimes this just happens.
Also you can build your application in debug mode, go to the output, run the program, and attach to that process. :P
Amazing answers already given but they dont help in the purpose. So here is my finding, no matter if i am late in answering, but it really works for me.
Even if you are developing a web app, just go to the website properties by right-clicking the project and then you see a "Web" tab on left as i have highlighted. Then just check the box saying "Enable Edit and Continue". Thats all you need to do. it works for me!
I had a similar problem, and solution was absolutely dumb. VS was confused with two instances of Internet Explorer in “Browse with” setting. So, I set Google Chrome (any browser) as default, and then set IE as default again. It deleted the other instance of IE (only one remained) and debugging was enabled.
Hope it help!
I had a similar issue.
I added up:
using namespace std;
and this solved the problem
For me, uninstalling the Redgate's Reflector plugin that had expired fixed it. I spent more than 4 hours uninstalling, rebooting, reverting to older code, etc etc..
When my default browser was changed to CHROME, I could no longer debug my User Interface. Setting IE back to the default browser fixed it. Alternatively you can attach the process plug-in during debug.
I had the same problem with my desktop application and as this forum says you should mark your project as a startup project, since visual studio has unmarked. It worked just fine for me an I believe it will help other people that may have this problem, since I believe you have finished this project.
One of my VB .NET Winforms projects wouldn't allow debugging.
This was due to the configuration manager set to 'Release' even though the toolbar dropdown indicated 'Debug'.
You need to select the mode dropdown and select the last option 'Configuration Manager' and ensure that the main project is set to 'Debug' and not 'Release'
Install Microsoft SSDTSetup.exe 450Kb and Close the SSDT tool during install. After installation open the SSDT tool and execute the script task and Component with breakpoint. Worked for me
try checking your output without debugging
Ctrl + F5
good luck

Visual Studio 2012 not compiling anymore after changes made

i recently installed VS 12 Service Pack 1.
Since then, i noticed Visual Studio doesn't compile my project on start if changes were made.
Normally if you start (debugging) a project which has some changes, it recompiles it and starts then. But now, i always get debugging errors like "this breakpoint can´t be reached, because the source code is unequal to the runtime code" or whatever.
It´s annoying to recompile it manually always before starting - I always forget that :-/
Is there any option to fix this?
Can you check if the build on run option is set?
You will find it under Tools->Options->Project and Solutions->Build and Run.
I dont have a good answer as to why this would have been flipped just via installing the update1.
I think that you should enter the Solution's Property Pages (by right clicking the solution in the Solution Explorer pane) and setting the 'build' check-box of the relevant project.

Method works in Visual Studio but not from exe

I have a really wierd problem with my app. When i debug the application from visual studio it works perfectly but when i execute the exe file from the debug folder one of the methods does not work at all.
the weird thing is that it is just one method everything else in the application works
i read up on similar types of problems and most articles go in the direction of the configuration manager where the setting for platform is set to 'anyCPU' i changed the platform to x64 because my development machine has a 64 bit OS but i still get the same problem occuring..
this problem has me stumped for the last couple hours....
any help would be appreciated
thanks
Are you sure that while debugging thru Visual studio u r not checking any properties manually(at run time)? I mean by putting some breakpoint and then traverse thru the property tree of the object. Because that can result in intializing some stuff which can lead to different execution path. I am saying this from my personal experience, as i was debugging and checked some properties at run time, which was resulting in desired result.
delete all .dll and .exe file in your solution directory(those which are solution's project output) and then rebuild all project
If you are working with webservices there could be the problem, that the answer from the server is to slow. while debugging the program "runs slower" and the answer has many time. Without debugging programm runs fast and you have the problem of the answer not beeing there when you need it.
I've had this kind of problem one time and too needed a long time to get the point ;-)
Another solution could be a different security police in and out of VisualStudio (I'm not really sure but sometimes it seems like Programs have more rights while debugging (at least on my PC)).

Edit and Continue is not working in VS2010

for some reason this no longer works. I ugraded the winforms solution from VS2008 to VS2010 and on new machine also Windows 7 64bit but id does not allow edit and continue
I haver set the options to enable it and to compile against 86 cpu
any ideas?
also Windows 7 64bit
Edit+Continue only works for 32-bit code. Easy fix, and the default now for VS2010 projects: Project + Properties, Build tab, Platform target = x86. You can of course leave that setting for your Release configuration at Any CPU.
try this link. quoting from it
Edit and Continue is enabled under Tools>Options>Debugging>Edit and Continue
My solution platform is set to x86
My solution configuration is set to Debug
All my projects are building for Debug and x86
For all projects under Projects>Properties>Build the Optimize code is unchecked
tools->options->unselect intellitrace events and call information
I know it's a old question... but I not found a similar answer on another question.
I was having this issue for months. I found today a solution on my PC (win7 x64):
I run VS2010 with administrator privileges (uac enabled, popup appears and I accept everytime that I run vs 2010) this is because I need a 3rd party addon to work.
It appears that running vs 2010 with admin privileges make it run on another account or something else...
I checked one setting on vs2010 that allowed me to edit and continue now again :)
this option is under:
Tools/Options/Debugging -> Edit and Continue -> check "Enable while remote debugging or debugging and aplication running under another user account"
note: vs2010 will show a warning (security related...).. I not sure how dangerous it is... but works
I hope that this solution can help someone.
In my situation, someone added a Reference to the Project's output into the Reference list: in Solution Explorer look under [ProjectName]\References for [ProjectName*] and remove it. If the project is relying on code from a copy of itself, you can't 'Edit and Continue'.
In the warning list you'll see conflicts with imported type messages if this was the cause of the problem.
I've seen this as well. It seems that some stuff of the expressions and lambdas cause this. ;(
I have the same problem and found this info from the MSDN page "How to: Use Edit and Continue (C#)" :
Note
Edit and Continue is not supported when debugging 64-bit code, the Compact Framework, optimized code, mixed native/managed code, or SQL Server common language runtime (CLR) integration code. If you try to apply code changes in one of these scenarios, the debugger puts up a dialog box explaining that Edit and Continue is not supported.
I think the mix of native/managed code is the problem for me (my project indeed mixes them).

Categories