Instance Hunter
Instance Hunter

Reputation: 7925

How do I remedy "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?

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

Answers (30)

juFo
juFo

Reputation: 18577

Check to make sure that you select "Debug" and not "Release" option. enter image description here

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:

  1. Right mouse click your project
  2. Select [Properties] (shortcut: Alt + enter)
  3. Select the [Build] tab
  4. Make sure [Define DEBUG constant] and [Define TRACE constant] are checked
  5. Make sure [Optimize Code] is unchecked
  6. Click the [Advanced] button at the bottom of the Build tabpage
  7. Make sure that [Debug Info:] is set to [full]
  8. Click [OK] and rebuild the project ;-)

(step 7 generates the .pdb files, these are the debugging symbols)

Upvotes: 760

Super Jade
Super Jade

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.


Solution #1

  • The solution you're working on must be added to source control.
  • The files you're setting breakpoints on must be added to source control.
  • Only extension files can have breakpoints hit using this solution.

If any of the above doesn't apply, breakpoints will not be hit.


Solution #2

If solution 1 above is insufficient for hitting breakpoints on your extension files, you can add them to the files to debug as follows:

  1. If you're already debugging, stop.
  2. VS > Tools > Options > Dynamics 365 > Debugging > Search Packages for your extension > Select your extension
  3. Happy debugging :-)

Upvotes: -1

bimal george
bimal george

Reputation: 313

  1. Clean solution and Rebuild
  2. Check the configuration is set to Debug
  3. Make sure that the PDB file is in the Debug folder it self
  4. From Debug menu click Enable All Break points

Upvotes: 12

theITvideos
theITvideos

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:

  1. Go to Debug from the menu bar
  2. Click on Attach to Process
  3. Near the Attach to option, click on the Select button
  4. The Select Code Type window will appear
  5. Now select the option Automatically determine the type of code to debug and click the OK button.

Fixed Debugging Error

Upvotes: 56

Craig
Craig

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

Hans Passant
Hans Passant

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

Tomasz Janicki
Tomasz Janicki

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

TEST Properties

Upvotes: 1

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

Ran Turner
Ran Turner

Reputation: 18116

  1. Make sure you're in Debug and not in release by choosing debug in the dropdown menu, as shown in the picture below.

enter image description here

  1. Then, try cleaning your project by clicking the right button in your mouse on the solution in the solution explorer window and choosing Clean solution.

enter image description here

  1. Then rebuild your solution by clicking the right button in your mouse on the solution in the solution explorer window and choose Rebuild solution

enter image description here

Upvotes: 14

lfassio
lfassio

Reputation: 23

I tried everything before of discovering that in my case the solution was:

  1. Tools / Options / Debugging / Just-In-Time
  2. "Managed" option was NOT checked, after checking it breakpoints worked like a charm.

enter image description here

Upvotes: 2

Karthik
Karthik

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

Datboydozy
Datboydozy

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

user1505521
user1505521

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

Sam
Sam

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

Bala Kumar
Bala Kumar

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

Kary
Kary

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

Stefanos Zilellis
Stefanos Zilellis

Reputation: 611

I solve this exact problem by:

 1. Open studio as administrator
 2. Use Build->Clean Solution
 3. Use Build->Build

Upvotes: 2

Peter Bäckgren
Peter Bäckgren

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

Hamid Mir
Hamid Mir

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

Mmm
Mmm

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

Amazigh.Ca
Amazigh.Ca

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

Serj Sagan
Serj Sagan

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

DDT
DDT

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

Mark Pazon
Mark Pazon

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

DDT
DDT

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

LuisEduardoSP
LuisEduardoSP

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

Sandip Bantawa
Sandip Bantawa

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.

  • IDE: VS 2013 Professional
  • Version: 12.0.40629.00 Update 5

Upvotes: 0

peter bence
peter bence

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

Nathan
Nathan

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

clamum
clamum

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

Related Questions