VS2010 can't debug, breakpoints are never hit - c#

My Excel AddIn was targeted to .NET 35 SP1, I just changed it to target .NET 4. Now I am not able to debug b/c breakpoints never get stopped. I can set breakpoints, but debugger never stops at any breakpoint. I check that all projects are in Debug configuration. thanks

I assume because it is an Add In, that you are attaching to the process, rather than the run/debug method?
If this is true, and you are attaching to the process make sure that you are attaching using Managed (v4.0), instead of Managed (v2.0, v1.1, v1.0). Debug->Attach to Process->Attach to:

My assumption is that your AddIn has been disabled in the registry or isn't being loaded. Check the Add-Ins window to see your plugins status.

Make sure that the build configuration is set to Active(Debug) or Debug under the build tab of the properties window.

Go to the screen shown for Debug, click the Advanced button on the lower right of that screen, make sure Debug Info is NOT "none". In other words, make sure the PDB is generated.

Related

Code Not Stopping On Breakpoints

I am using VS2015 and have a C# / ASP.NET webforms project which is working well. However, now I am needing to add new syntax and test it, so I opened it and set a few breakpoints, but the code is not stopping on the breakpoints! I opened both webconfig and Webconfig and they both have debug=true I also tried to re-build my project from the build menu and this did not solve it either. So what else should I do to get debugging working?
EDIT
and yes I am set to debug configuration, see image
Make sure that in addition to setting debug in Web.config that you've selected the DEBUG configuration for the project in Visual Studio. Look for the dropdown box in the toolbar that has Release vs. Debug. If it wasn't in Debug, rebuild all after that and confirm you still have zero errors.
Then make sure you are attaching the debugger. If your web project is the default, then the little green arrow next to the debug/release dropdown will launch a web browser on your site and (critically) attach the debugger. As long as you keep that browser instance running, the debugger will stay attached and you'll hit breakpoints even when someone else and/or another browser hits your site.
Finally, be aware that without some special tricks, it is very hard to hit breakpoints in Global.asax:Application_OnStart because this code runs before the debugger has a chance to attach. You can add trace statements in there and then view them after the fact though.
Posting this since it seems to have been the answer
I usually see this happen when the IDE is running from an old copy of the assembly. For instance, if you had two branches of the same project open and built... sometimes your changes aren't caught as being changes so you end up running on an old build. I'd shut down every other instance of VS, clean the current instance then shut that instance down. Make sure IISExpress is also shut down (check the tray). Then start it back up and try again

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

What does it mean to attach to process in Visual Studio 2010?

I have seen this option under the debug menu, but I don't completely understand what it means. Could somebody explain it to me? Thank you in advance.
When you Attach to a Process, you're causing the debugger to attach to the process and allow you to set breakpoints within code that you have not started from a debugger. This is very useful in the situation of trying to debug things that have an automatic spawning process (such as .NET code that runs under IIS).
Instead of pressing F5 to start an instance of your app (or pressing the green "go" button), you can attach the debugger to an already running program. While you /can/ attach to an instance of Notepad, since Notepad is not a .net application and you don't have the .pdb debugging symbols for notepad, it won't do much good.
To attach to an already running instance of your program (or an internet explorer instance that is running your code)...
compile non-optimized
compile "Full" debugging symbols (the
default for the DEBUG configuration)
make sure the .pdb file is in
the same directory as the .dll or .exe (or you can find them manually)
make sure the code is in the same path as when it was compiled (or
you have to find it manually)
I don't know what the official documentation says, but this is how I use it.
If you are working in a project that runs continuously, say a web site deployed in IIS or a windows service and you have the solution with the code of the running program open in VS, you can attach to the process and debug it as if you had launched it hitting F5, set breakpoints, etc. It also allows to attach to a process running in a remote machine if it is properly configured, which turns out to be useful if you are debugging a process in a staging server or something like that.
You just need to make sure that the code you are editing is the one used to compile the binary.
You can attach the debugger to a running process and start debugging it where its at. Mostly useful only if you have the debugging information for the executable.
I tend to use it if my program hits an exception and I'm not already debugging it. I can attach and then view the variables and call stack.
That means to attach a debugger (i.e visual studio's integrated debugger) to the process so you can pause it and inspect variables at runtime. This happens when you hit F5 automatically, or can be done manually using the debug menu.

is it possible to edit code while debugging in visual studio, like in eclipse (java)

Is there an option to edit the code when debugging in a breakpoint in Visual Studio. When I stop, all files seems locked for editing.
Is there a way to change this behaviour? It is possible in Eclipse
EDIT: after trying all suggested below (including move it to debug from release) now it is telling me I don't have the correct ms-office version and debug cannot start in debug mode. However, in release mode it was working. I am trying to debug an outlook add-in.
Yes, it's called "Edit and Continue", in Tools | Options under Debugging. Note that it's not compatible with IntelliTrace, so you have to disable that if you're using it. (Thank you Anton Semenov for that info.)
Edit: If you're using a really old version (the original VS.Net, as opposed to VS.Net 2005 or later), it was pretty fiddly about this (or didn't have it, I can't quite recall; I just remember being frustrated). But if you're using VS.Net 2005 or later, in my experience, it's enabled by default and works very well. When execution is paused (and you said you'd hit a breakpoint, so...), you can make quite a variety of changes and the environment will happily compile them and continue. Make sure all of the projects you want to debug are in the solution.
In general, it is possible, but you have to make sure you are compiling your project to x86 platform.
For this, right click on the project name in the Solution Explorer, go to Build and set the Platform Target to x86.
Edit:
Of course, in order to be able to edit a file, the execution need to be paused (in a breakpoint, for example)
yes you can update code in debug mode. Set the break point to the point which u want to edit . When the execution comes to this point then edit your code then press f5. It will take the changes.
win7
Yes, it's called "Edit and Continue", in Tools | Options under Debugging. Note
that it's not compatible with IntelliTrace
win10
can turn on IntelliTrace
# How to set a Visual Studio breakpoint to pause execution of your program at that point
To set a breakpoint, first decide which executable line of code you want the program to stop on 'Before' that line of code is executed.
Set the cursor flashing anywhere on that line.
Press [F9] to set the breakpoint, and a red circle appears on the far left.
Press [F5] to run program.
To close the program, click on the program window so that it is your active window, and press [Ctrl]+[Pause].
To disable the breakpoint, but not delete it, set your cursor flashing on that line again, and press [Ctrl]+[F9], which turns the circle white. (Or Right-click the red circle, and click "Disable Breakpoint")
To delete the breakpoint, Right-click the red circle, and click "Delete Breakpoint".
Using the mouse as an alternative way to set, disable, or delete breakpoints
Once you know where the breakpoints show up on the left side of the Visual Studio window, you can set a breakpoint by double-clicking at the point where you want the breakpoint to be placed, and it will be placed there.
If you double-click a red breakpoint, it will be removed.
If you hover your mouse pointer on a breakpoint, two little icons appear slightly above, and to the right of the breakpoint.
Clicking that right-side icon toggles the breakpoint from active to disabled, and vice-versa.
For many more details, see the topic:
"Getting Started with the Debugger"
https://msdn.microsoft.com/en-us/library/mt243867.aspx
Also, see the left column on the page from the link above for the additional pages:
"Navigating through Code with the Debugger"
https://msdn.microsoft.com/en-us/library/y740d9d3.aspx
"Using Breakpoints"
https://msdn.microsoft.com/en-us/library/5557y8b4.aspx
Video: And for a 5-minute introductory video, see:
"Debugging in VS Code"
https://code.visualstudio.com/docs/introvideos/debugging

Debugging into C# code from other application

I'm loading a dll (c#) from QTP. Is it possible to debug the c# code when the qtp test starts.
Yes you can debug into the dll's you can, but you will need source (unless you want to look at the disassembly) and you will also need the PDBs (debug symbols) for the assembly. It is pretty easy to setup...
start the QTP application
start visual studio
open the source code and make sure the pdb's are in the same directory as the dll
in VS go to the debug menu and select attach to process
In the process list, select the QTP process and click "attach"
Set a breakpoint in the code
Start the tests that execute the code and if all is well you should hit the breakpoint
NOTE: if the breakpoint is not hit, VS probably can't find the PDB's and you either need to add a path in options in VS (or something so it can find them).
Also, try turning off "Enable just my code" in the Tools->Options->Debugging options page if it is still not working (mostly if you are looking at release built code).
Update: Answering comment... If you go to Tools->Options... Select "Debugging" on the list on the left and expand that, then select "Symbols" you can add paths there for VS to search for symbols. Also, if you don't have the exact symbols you can right-click the breakpoint and select location and check the option that will allow the symbols to be out of sync.
Hope this helps!
You can insert a call to Debugger.Break()and run the external application, when the break point will be reached Windows will offer you to debug the exception.
Choosing debug will enable you to run the code after the break inside Visual Studio and set break points inside your code.
In case you're using Vista/Win7 you might need to enable debugging - have a look at this post to learn how.

Categories