In VS2017 breakpoints not hitting sometimes - c#

I'm using VS2017...my breakpoints are not hitting sometimes...when i put a cursor on breakpoint I'm getting an error called "The breakpoint will not currently be hit.No Symbols have been loaded for this document." Can any one help me on this issue.Thanks!!

This happens to me when the code has changed but the build doesn't pick it up. For example, if the code doesn't match the pdb file, then you'll see this.
Clean the build and then build it again, and try again.

Related

Breakpoints not hit in specflow

I'm writing a test case using SpecFlow in C#. When I set appropriate breakpoints and run the test cases using debugger, all the breakpoints are not hit. When I hover over them, a tip displaying "The breakpoint will not be hit. No symbols have been loaded for the document" is shown. Now, how do I debug the testcases that I have written?
PS: I'm using VS2015
I solved my problem by going to Debug->Options and disabled "Just my Code" option. Then I navigated to symbols and checked "Microsoft Symbol Servers"
Try to build the complete specflow project with specflow definition file as well.Hope it should solve the problem.

Breakpoints are not hit. I get "breakpoint will not be hit, the code source is different" message

Working on an old ASP.Net project using VB. I am using VS2012.
The debugger does not handle my breakpoints for a specific class (no prob with other classes so far).
When I run the app without having changed the file, its breakpoints are correctly hit. If I change anything into this file (even adding a \n character), the next time I run the app, its breakpoints are not hit anymore and I can read under the breakpoint the usual warning saying that "breakpoints will not be hit because the source code is different".
How can I have the debugger to accept my changes into this file? Why is it only causing trouble with this specific file?
I tried to remove my ASP temporary files as suggested in other similar posts. Did not help.
Rebuilding does not help either.
Thx in advance
Solution 1: Right click on the break point->Location->Allow the source code to be different from the original version(Tick the check box).
Solution 2: If the above solution doesn't work goto Debug->Attach to process, then attach the port/ service in which your current web project runs.
Hope this helps.
I would make sure that you currently have the Configuration Manager set to "Build" the ASP.NET project that you're making changes in. This is found under Build -> Configuration Manager.
Then rebuild the solution/project.

breakpoint isn't hit when running 2 instances of the same project on VS2013

I created 2 instances of same project to apply different changes. So when I open project1 and debug class1, everything is smooth, I can have my breakpoints hit all other debugging features.
When I open project2 and close project1, I try to do same debugging on class1(some lines of the code is different), I get warning that
"the breakpoint will currently not hit. a copy of class1.cs was found in project1.dal.dll, but the current source code is the different from ther version"
When I close the VS completely and reopen the projects or If I clear the Temporary ASP.NET Files, Problem is getting resolved. But it happens everytime for me. so my questions are;
1) I wonder why does it happen and how can I resolve it without closing VS or clearing cache files?
2) I know the option called "Uncheck Require source files to exactly match the original version".. Is it safe to do it? or is there any side affects or disadvantages
It is impossible to debug your code in that way - you are creating different symbols for each build so when you debug one version, the other is not compatible with the previous one.
To make the long story short - you cannot debug one version of code when symbols from another version are loaded.
More info: Fixing "The breakpoint will not currently be hit. No symbols have been loaded for this document."
EDIT:
Check this link also: What is the "Temporary ASP.NET Files" folder for?

Cannot debug into the code

in one line of my solution which is made of a couple of projects I want to debug one line of code, something like this:
mThisLibrary.DoSthMethod();
but when I put my break point on that line and press F11, the debugger says that "There is no source code available" so I cannot get into it deeper. BUT the source code is there so for example if I click F12 on the method name, I can go to its implementation easily. I am not sure why the debugger cannot get inside that method.
Any ideas?
Make sure that the assembly you are referencing was built with a Program Database File for debugging purposes. If the debugging information is not present, this can happen.
Typically, if the library is part of the same solution, just make sure that all of the projects are being built in Debug. By default, Debug will generate the .pdb files required for debugging, as well as turn off the optimizations that can sometimes cause debugging difficulties.

break point is not hitting while debugging

Possible exact duplicates:
Reason for VS.NET ‘current breakpoint will not be hit’ warning?
Why does Visual Studio sometimes not go to my breakpoints?
Why would the debugger not be stopping at a breakpoint in my ASP.NET application?
while debugging,the modified source code the break point is not hitted for a particular aspx page and the following error is shown in the break point
"the break point will not be currently hit.the source code is different from the original version"
but for other page it is working fine.
It worked for me. Try this.
First try rebuilding your project by right mouse click the project > Rebuild If that doesn't work, try a clean of the project (right mouse click on the project > clean)
If that didn't work check this:
1- Right mouse click your project
2- select [Properties]
3- select [Build] tab
4- make sure [Define DEBUG constant] and [Define TRACE constant] are checked
5- Click the [Advanced] button at the bottom of the Build tab page
6- Make sure that [Debug Info:] is set to [full]
7- Click [OK] and rebuild the project ;-)
Hope that works for you! (step 6 generates the .pdb files, these are the debugging symbols)
Some times this occurs if the sourcecode is been copied from the network folder, it messes up the symbol settings. Below solution works for me everytime
In debug mode, select debug->windows->modules
Check your dll symbolStatus . Make sure that it is loaded into
the project (i am sure now the status
is not loaded )
Right click your dll, click symbol settings.
And manually add your symbol path (.pdb file path)
And again right click the dll, and click load symbols
Hope this helps
That suggests the build that's running doesn't match with your code.
Try performing a "clean", make sure that you've stopped any previous debugger sessions etc, then rebuild and retry.
make sure there are not instances of w3wp.exe running. I had several and closing them fixed it for me.
Visual studio repair solved the problem for me
search for visual studio installer in start
select more option for the version you are using and click repair.
In my i changed the connection string but in the browser it was referring to old string so i just did 'empty cache and hard reload in chrome browser' and it worked
This problem occurred to me when I had copied the project. In fact, by opening the old code file if breakPoint is inserted, you will see that it will work. So learn the correct copying method.

Categories

Resources