Reputation: 7925
A C# desktop application (on the Visual Studio Express edition) worked, but then it didn't work 5 seconds later.
I tried the following:
I have two Windows Forms projects in the solution. One of them loads the debug information, one doesn't. They both refer to the assembly I'm trying to get debug information on in exactly the same way in the project file. Any ideas?
I want to add here, mostly for myself when I come back to review this question, that symbols are not loaded until the assembly is loaded, and the assembly is not loaded until it is needed. If the breakpoint is in a library that is only used in one function in your main assembly, the symbols will not be loaded (and it will show the breakpoint as not being hit) until that function is called.
Upvotes: 2129
Views: 1864047
Reputation: 18577
Check to make sure that you select "Debug" and not "Release" option.
If does not work , try rebuilding your project by right mouse click the project > Rebuild
If still doesn't work, try a clean of the project (right mouse click on the project > clean)
.
If still didn't work check this:
(step 7 generates the .pdb
files, these are the debugging symbols)
Upvotes: 760
Reputation: 6374
How do I remedy "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?
I got this error using Visual Studio 2022 and Team Foundation Server with a Microsoft Dynamics 365 project. My teammates, who did not wish to answer themselves, provided solutions.
If any of the above doesn't apply, breakpoints will not be hit.
If solution 1 above is insufficient for hitting breakpoints on your extension files, you can add them to the files to debug as follows:
Upvotes: -1
Reputation: 313
Upvotes: 12
Reputation: 1502
I was able to fix the error by simply setting the option in the 'Attach to Process
' to 'Automatically determine the type of code to debug
' option as shown in the attached screenshot.
Simply follow the steps below:
Upvotes: 56
Reputation: 445
I tried cleaning, rebuilding, deleting bin and obj folders, fiddling project settings. What worked for me eventually was using Debug --> Delete All Breakpoints and then re-adding those that I needed, then rebuilding.
Upvotes: -1
Reputation: 942128
Start debugging, as soon as you've arrived at a breakpoint or used Debug > Break All
, use Debug > Windows > Modules
. You'll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You'll get a dialog that lists all the directories where it looked for the .pdb
file for the assembly. Verify that list against the actual .pdb
location. Make sure it doesn't find an old one.
In normal projects, the assembly and its .pdb
file should always have been copied by the IDE into the same folder as your .exe
, i.e. the bin\Debug
folder of your project. Make sure you remove one from the GAC if you've been playing with it.
Upvotes: 1341
Reputation: 99
Apart from all super useful answers. I was looking into a debug when running a Test. What I had to do was to set Test Properties > Debug > Enable native code debugging.
My application is a mix of C# and C++. C# code was debugable by default, but C++ had to be enabled. That setting below did the trick. Enable Visual Studio Hosting Process is disabled in my properties.
Very similar answer to what was said (years?) before but here I am clear one has to set it in the Test Properties
Upvotes: 1
Reputation: 21
I had reset the settings of the Visual Studio and then, when I executed a project, it shows the breakpoint like disabled.
Solution: Project was running in the Release mode, you can switch to the Debug.
Upvotes: -2
Reputation: 18116
Debug
and not in release
by choosing debug
in the dropdown menu, as shown in the picture below.Clean solution
.Rebuild solution
Upvotes: 14
Reputation: 23
I tried everything before of discovering that in my case the solution was:
Upvotes: 2
Reputation: 1587
The Following steps worked for me:
1. Go to the "bin" folder of your project.
2. Delete the "Debug" folder.
3. Build your project again.
4. The Debug folder will get re-created.
Now you can start debugging again.
Upvotes: 3
Reputation: 141
I was facing this issue in Vb.net with an Autocad project and none of the above solutions worked for me. Turns out the dll I was trying to run was already loaded in the Autocad dll folder. This was causing conflicts when I ran the command that would invoke said DLL. My solution was to remove the dll from my Autocad dll folder and ran it with the dll from my project folder. This fixed this issue.
Upvotes: -1
Reputation: 241
The issue was my symbols were being brought from virtual directory path of the project... and it was mapped to the virtual directory of some other project instead... the web project that was supposed to load in the modules was not there
Following are the steps I followed:
- Right click the specific web project and select properties
- Go to Web tab
- You can see the Create Virtual Directory button
- As soon as I clicked it I saw an alert message saying "the
(projectname) is mapped to (anotherProjectName)" are you sure you
want to do the remapping?
Something like this
- then it made sense that for why I was seeing the unnecessary
project name in the modules window
- Then I rebuilt the solution and was able to hit the breakpoint
Upvotes: 2
Reputation: 348
In my case, I was compiling a class library (DLL)
.
No modules seem to be loaded in Debug -> Modules
, so I couldn't even load the symbols manually.
My solution was to add this line to my code:
System.Diagnostics.Debugger.Launch();
Once this code is reached, an exception is triggered and .NET Framework
shows a dialog box asking which Visual Studio (i.e. new instance of VS 2008
, new instance of VS 2013
, etc
) you want to use to debug the program.
You can choose the existing instance of VS with your project loaded.
This will attach the process to your VS
session and load all symbols, and now you can debug your project.
Of course, the compilation has to be done using the Debug configuration, not Release
.
Upvotes: 6
Reputation: 677
If we get the latest from VSTS
, all files will be in read only mode.
While running project all class library classes get read only and breakpoints turn empty and say "Breakpoint will not currently be hit
.
No symbols loaded for this document".
Solution 1
Go to the project location and right lick the:
folder ---> Properties ---> General Tab ---> UNCHECK read-only
(Only applies to files in the folder) ---> Apply ---> Ok
Solution 2
Start debugging,
Go to Debug ---> Windows ---> Modules.
Select one assembly and Right-click ---> (Select) Symbol Setting.
Set Your Bin path in Cache symbol in this directory and select Microsoft
Servers in Symbol of PDB location
.
Click Load All Symbols. It will take time. Then click OK.
Now the symbol status of all assembly has been changed from "can not find or open PDB" to "Symbols loaded
".
Upvotes: 4
Reputation: 21
I was integrating a C# application with a static library using VS10
- which I'm new to.
I wrote a managed code dll
to interface them. I could set breakpoints everywhere but the static lib
.
I got the message described above - no symbols have been loaded for this document. I tried many of the suggestions above.
I could see that the symbols weren't being loaded. I finally noticed a check box Configuration Debug, Enable unmanaged code debugging.
That allowed me to set breakpoints in the static lib
functions.
Upvotes: 8
Reputation: 611
I solve this exact problem by:
1. Open studio as administrator
2. Use Build->Clean Solution
3. Use Build->Build
Upvotes: 2
Reputation: 71
Was totally baffled by the "symbols not loaded" although w3wp.exe often has breakpoint problems.
At the end the reason was I had one disabled breakpoint in another location (kinda use disabled breakpoints as bookmarks at times). After removing it, breakpoints became red again. Adding another disabled breakpoint and removing it didn't make the problem re-appear.
This explains why often the only solution is to delete the .vs cache (overkill and tedious) as then also the disabled breakpoints get removed.
Upvotes: 1
Reputation: 373
For whom may not find any of these solution working, this may help: I did a mistake and in my web.config added this to connectionString:
server=localhost; port=####
this caused debugging stop, I removed it and it fixed
Upvotes: -1
Reputation: 961
One more answer for those using ASP.Net (framework) WSP application.
The only way I could get VS to debug properly was to make sure debug="true"
in your web.config on the compilation
line:
<compilation debug="true">
Upvotes: 0
Reputation: 3543
If you have more than one project in your solution, may be the project you are debuging/breakpoint is not set as Startup Project. In my case, i'm calling a web service from an other project in same solution, so the web service was not Startup Project and brfeakpoint was not hitting.I set the ws as startup project and started a new instance of the calling project. It worked for me.
Upvotes: 0
Reputation: 30247
Sometimes, even though it gives you this error, the Breakpoint
still gets hit, so just ignore the error.
This happens fairly often in the Views
of an MVC
web app, i.e. .cshtml
.
Upvotes: 68
Reputation: 49
My solution was to change the Visual Studio version (I was trying to open it on VS2013, ended up opening it on VS2015).
Upvotes: 0
Reputation: 6205
Make sure that you are referencing the right class.
In my case I have a GameObject in which I added the wrong script to the components. Hence, there is no way for Visual Studio to actually reach the code.
I simply had to delete the wrong C# script and component and add right one.
Upvotes: 1
Reputation: 49
Right click on the project -> Properties -> Web tab
In Servers section I changed IIExpress for Local IIS, created the virtual dir, and voilá!
Upvotes: 0
Reputation: 401
My issue was that the aspx, aspx.vb and aspx.designer.vb files were imported wrong (Perhaps they were imported one by one to the project).
The breakpoint were in the aspx.vb, but was unreachable and had the warning of this question.
The solution was to delete the three files and import them again. Now I can reach the breakpoint.
Upvotes: 0
Reputation: 2880
I had same problem, checked all the previous solutions but didn't work for me. Simple but added answer just to make sure people don't get stuck on this not to exist problem as I did.
What worked for me was, I was running VS 2013 on admin mode and running on normal mode did the trick. Tried multiple times switching to normal and admin mode and its consistently working fine.
Upvotes: 0
Reputation: 822
If you are using a C++ project or a DLL from a C# or any .NET project, and you want to debug into the native code. Then go to the .NET Project Properties -> Debug -> Enable native code debugging (set it to true).
Upvotes: 1
Reputation: 889
Another solution is to make sure that your code is reachable. For example:
Any code that is added after a Return in a function. Adding a GOTO that effectively skips your code that has the break point.
I'm not saying these are normal, but they are also causes.
Upvotes: 0
Reputation: 1374
Normally our apps at work reference .dlls in a particular common/app directory, like this: C:\OurCompanyApps\xxxxxx.dll. This was happening in a solution that has a bunch of WinForm and .dll projects in it. The .dll projects compile to C:\OurCompanyApps\ and the WinForm projects reference the compiled .dll files in that location.
The problem: I found that the app in question was referencing the .dll project in the Source Control bin\Debug location instead of the compiled .dll file in C:\OurCompanyApps.
Solution: I deleted the reference and re-added it from the C:\OurCompanyApps\ location. Then I could step-through the breakpoints I had added in the .dll code.
Upvotes: 2