343

Ok, what I have:

Visual Studio 2010 RC, W7 x64, started a new project type of Silverlight application. Hosting the Silverlight application in a ASP.NET Web Application Project. Silverlight Version 3.0. Added a LinqToSQL Class, a WCF Service, a Winform Tester Application (Project in the Solution) and a few Classes (also as Projects in the Solution).

Yesterday, suddenly I got the 'The breakpoint will not currently be hit. No symbols have been loaded for this document.' message to appear in the IDE, but it only affects the Web Appliaction, I can debug the Silverlight and the Winform App.

What I tried / did to get rid of the message:

  • Reset Visual Studio Settings
  • removed all files in every \Temporary ASP.NET Files Folder (there is one for each 32bit/64bit and for Framework 2.0 and 4.0)
  • tried to debug using Visual Studio Integrated Web server - normally I use IIS, in the project output of the solution I deleted every obj and bin folders in every project folder
  • created a new solution and added all the projects to this new solution
  • deleted the solution suo file
  • created a new ASP.NET Web Application to test if it is a VS-installation issue => I can debug this new project/solution
  • rebooted the machine several times
  • repaired the vs.net installation
  • did an IISReset
  • removed the Web App from IIS
  • used the Create Virtual Directory Button under Project Properties of the Web App to create a new Web App in IIS
  • changed the Framework Version of every project from 3.5 to 4.0
  • Opened the Solution on my second machine => same behavior
  • crawled Microsoft Connect for bugs / similar issues
  • SPENT 7 HOURS.

So, this happens the 2nd time in my life. last time I solved it by deleting Temporary ASP.NET Files Folder, but this time I need your help.

1
  • In my case, turning off Optimize Code in Build tab of project properties fixed the problem. Commented Jan 2, 2017 at 21:10

50 Answers 50

179

Right click on solution --> Properties

Look under Common Properties --> Startup Project

Select multiple startup projects

select Start action on the projects you need to debug.

6
  • This worked but I had to do it a few times (VS 2010, built-in webserver, website)
    – MGOwen
    Commented Jan 24, 2012 at 9:18
  • 17
    i have multiple projects and start them as u tell.. some of them are class library projects.. follwing error popup appears: "A project with an Output Type of Class Library cannot be started directly" Commented Oct 19, 2012 at 10:31
  • 3
    I'm having the exact same issue that Muhammed commented about. The project that VS doesn't load symbols for is a library project. Interestingly, another solution that links to the same library project has no trouble debugging that very same library! Commented Mar 11, 2014 at 21:35
  • 1
    I don't think this is an answer to the question. It just sets multiple project to start at the same time, instead of just one which is typical. If the project is a Class Lib (dll) then it's going to show an error message saying it can't be started. Whether or not a project is a start project or not has no bearing on debugging.
    – Greg Gum
    Commented Feb 3, 2015 at 17:39
  • In my case, I had reconfigured the IIS site running my project to point at a different folder. Somehow this had cleared the solution setting indicated above...? May have been a source control error, but I couldn't find a change to the .sln. Anyways, resetting this as described resolved the issue - hope that insight helps someone.
    – brichins
    Commented Aug 26, 2015 at 22:33
81

I had the same issue and after googling I found two typical solutions for this:

  1. Make sure the Silverlight debugger is activated in the .Web project. Open up the project properties and select the Silverlight debugger under the "Web" tab.

  2. Restart Visual Studio and delete all bin and obj folders.

But none of these worked for me. Then someone mentioned far down a thread to try using IE as the browser instead. This made debugging and breakpoints work again!

Edit:

Later I have struggled with IE9 not working, because it attaches to the wrong process. Instead of manually attaching to the correct IE process every time, I found a neat trick:

  • Right-click one of the generated pages in the .Web project (.html or .aspx)
  • Click "Browse with..."
  • Set IE as default browser (will only affect Visual Studio's choice of browser)

Now, Visual Studio will launch IE when running the .Web project and attach to the correct process. That should do it.

9
  • Thanks,this just worked for me! Only problem is: I can't set which browser to run in any config files (can I?), so now I'm stuck as IE as my default browser. Bah.
    – DanTheMan
    Commented Apr 5, 2011 at 19:47
  • 1
    To avoid having IE as my default browser, I changed the launch settings in the .Web project to run IE with the path as command line parameters.
    – angularsen
    Commented Apr 19, 2011 at 14:39
  • You are awesome. I have been struggling with this issue for the last few days. I even reinstalled visual studio. My default browser was firefox, I tried chrome. It just didn't strike my mind to try IE, what a waste of time. Thanks for the info.
    – coder
    Commented Oct 4, 2011 at 5:43
  • My previous comment about launch settings should not be followed when fixing the problem as explained in my edited answer. Just use the default "Specific page option", or else I believe it may attach to the wrong process.
    – angularsen
    Commented Nov 9, 2011 at 19:44
  • 6
    I've check "Silverlight" checkbox on "Web" tab in the .Web project settings. Now it's work. Thanks! Commented Jan 20, 2012 at 6:56
53

Whenever I've had this particular error come up, it's turned out that the folder that Visual Studio is loading assemblies from is different from the folder the web-application is running from.

That is, the application server is running the application from

C:\dev\MyApplication\bin 

but Visual studio is debugging from

C:\dev\MyOtherApplication\bin (or something along those lines, anyway).

Note - for various reasons, I do my debugging with IIS as the application host instead of the dinky standalone gizmo that most people use. This could influence the usefulness of my answer!

Update:

For IIS the application server directory (i.e. C:\dev\MyApplication above) is the physical directory configured for the web application - this can be controlled by changing basic settings for the app.

For Visual studio the debugging directory (i.e. C:\dev\MyOtherApplication above) is the directory in which your svc files are found, usually the same directory as your csproj project file.

7
  • 2
    Maybe, but Hans K's answer worked for me. I guess there's multiple answers depending on the situation. Commented May 9, 2011 at 22:21
  • OK, but how do I know if this is happening? How do I fix it?
    – MGOwen
    Commented Jan 24, 2012 at 8:52
  • @MGOwen - in your IIS configuration, check the physical location for the virtual folder containing your services, and make sure it matches the output directory from VStudio.
    – Bevan
    Commented Jan 25, 2012 at 18:30
  • Yes, I was also working with IIS, but after VS crashed, my solution file became corrupted, so I had to pull it from subversion again. Of course, I forgot that by doing this, it reverted back to using VS webdev server. Duh! Thanks! Commented Nov 29, 2012 at 13:54
  • 3
    When VS gets confused, make sure to go back to the Debug profile. That got me. Commented May 16, 2013 at 22:24
47

The problem for me turned out to be that the Properties->Build->Optimize code checkbox had been turned on in the Debug configuration. Turned it off, rebuilt, and debugging worked as normal.

1
  • 1
    Project set to release build. There's always something isn't there. Commented Jan 8, 2018 at 21:22
22

The reason for what you faced is that the PDBs ("PDB stands for Program Database, a proprietary file format (developed by Microsoft) for storing debugging information about a program) are not up-to-date, this may be due to some reasons:

1- As Bevan said, you may be debugging another application!

2- You are debugging another version of the same application. For example, you attached a previously built application with the current version of the code for debugging without (re)building it.

Cleaning or Rebuilding the Solution solves such problems for me.

To make sure the problem is not yours, try debugging the same application with VS 2008 (I am afraid it may be a bug in VS 2010 -- it is still beta!).

5
  • thanks for the heads up.. of course i cleaned / rebuilt the solution but that didn't help. Point 1: how can i debug another app if i tried it on another system? same for Point 2. by the way, it's RC and pretty stable at all.. thanks anyway. Commented Feb 20, 2010 at 8:03
  • I did not quite understand your phrase "i tried it on another system"!. Release Candidate does not mean it is bug free, and you will loose nothing if you try it. If you are using IE8, some people said it may be the root of the problem, check this: weblogs.asp.net/abdullaabdelhaq/archive/2009/06/01/… Commented Feb 20, 2010 at 11:29
  • I found this also: stackoverflow.com/questions/389290/… people suggested too mush solutions there. Give a look to the inline break point comment there. Commented Feb 20, 2010 at 12:04
  • ok i see. my phrase 'i tried it on another system' => copied the solution on a usb stick, deleted all bin/obj folders, opened the solution in VS.NET and tried to debug it. result: same behavior => breakpoint's don't get hit .. thanks for the other link, i'll read it right now. Commented Feb 20, 2010 at 12:24
  • Clean + Rebuild doesn't always update .pdb files. What I did - went to /Bin folder of my web app and manually deleted all .pdb files, then rebuilt. Worked like a charm.
    – Dmitriy
    Commented Oct 27, 2011 at 9:49
22

I had the same problem, I was debugging my project, and i had to right click the project and select "new debug instance". I only needed to do this once, then after that it worked as normal.

1
  • Very strange. I had the same problem and googled it for 2hrs. For some reason the Module was not loading when I debug (Debug-->Windows-->Module). I just tried this options and boom debugging started working. I was using Vs2019 Commented Jan 31, 2020 at 22:07
18

This error crops up every now and then for me and I can always trace it back to project settings for the assembly concerned. You dont have to "wait" until your code fails to respect a break point or until you set the break point, to know which assemblies have symbols loaded.

When you run a project in debug mode it will list in the Output window which assemblies have symbols loaded as below (You may need to open the image in a new tab): T

Output window

So in this case BASD.Core.Data.dll does NOT have symbols loaded. So you can then compare the project settings for this assembly to that of another assembly that did manage to load symbols, in order to work out why some do and some don't load symbols.

"For me" however, "every" time this happens it's because the Debug info is not being created. So i open Project Properties > Build > Advanced in a (C#) project.

So for Basd.Core.Data.dll above i.e. no symbols the advanced build settings were:

pdboff

Whereas for Basd.Core.Configuration.dll i.e. an assembly where I could set and hit a breakpoint the settings were:

pdbon

So I'm outputting debug info in the latter project and not in the first, hence my ability to hit the break point in Basd.Core.Configuration.dll

Also note that it's not enough to simply have a .pdb file in the bin folder of a project for a given .dll because it might well be out of date and therefore not picked up by Visual Studio as a valid symbol file for the .dll you're trying to step through.

Also note that changing build configurations can change the build info settings and where symbols get pulled from.

(I realise in this case I'm in Release mode but the method still applies)

1
  • 1
    You can also check which symbols were loaded via the Modules window. If you go to Debug > Windows > Modules, it lists all of the modules and their symbol status. For ones not loaded, you can right click on them and click "Load Symbols". This is more of a short term fix though, and only works if they show up in the list to begin with.
    – EF0
    Commented Dec 15, 2015 at 19:57
14

Goto Project Properties -> Build -> Advanced...

In the "Output" section select "full" in Debug Info dropdown

2
  • I was trying to attach debugger to the release profile and this worked for me!
    – imlokesh
    Commented Apr 29, 2015 at 18:44
  • God bless you my child. Commented Oct 19, 2018 at 12:49
13

Make sure you are running your program in DEBUG mode and not RELEASE mode.

1
10

Debug - > Attach to process ->
choose Debug these code types: option ->
select Managed v3.5, v3.0, v2.0 or Managed v4.5, v4.0 enter image description here

1
  • This is the issue I ran into. I have some projects in v4.5 and others in v2.0 (yeah, I know, I know...). Apparently, this setting is not project based, so when I set it in a v4.5 project, I had to set it back when I went into a v2.0 project.
    – L_7337
    Commented Jun 6, 2016 at 12:44
9

I've just resolved this issue according to Deploying Silverlight Applications. (This answer is a duplicate of some others but I'll attempt to explain it more thoroughly.)

The problem is most likely that your Silverlight application is not being deployed properly to your web application on build / startup. This is a referencing problem - it's simple to understand but not obvious the first time you encounter it.

Just like any other project reference, the referenced project's output should be copied to the referencing project's bin folder in order to debug. For class libraries this happens when you right click and select 'Add Reference...'. For Silverlight, you should add a reference through Project Properties.

  • Right click your project, and select 'Properties'
  • Select the 'Silverlight Applications' tab on the left
  • Press the 'Add...' button and select your Silverlight project from the dialogue box

This adds a reference to the Silverlight application from your hosting web app, and ensures that the xap file will be copied to the web app on build or deploy. That means that the current Silverlight app and its debug files are inside the application being debugged, and you'll be able to step through the code.

0
9

If you're debugging a web project, make sure the debug="true" attribute has been set in your web.config file:

<system.web>
    <compilation debug="true"   .../>
8

I had the same problem on Windows 7 and tried everything: cleaned DLLs, investigated modules' list, turned off "Just My Code", and so on.

The problem was solved after I've run Visual Studio "as administrator". Honestly. Why Microsoft couldn't just warn me that it's not running "as administrator"? It would save me some hours of work.

0
8

For me the issue was that I had "Optimize code" enabled in the Build tab of my project's settings.

7

Had the same problem

For some reason, one of the DLLs was registered in the GAC, therefore it always had a different version than the code.

Once I removed it from the GAC, problem was solved

3
  • You mean how did it get to that situation? Or how did I remove it?
    – Stikut
    Commented May 13, 2014 at 8:40
  • How did you remove it. I'm having the same issue and can't fix it. I've tried everything so I was hoping that this was my solution.
    – Gaui
    Commented May 13, 2014 at 9:46
  • 1
    I hope you could use this one: support.microsoft.com/kb/873195 Unless of course you have some other error
    – Stikut
    Commented May 13, 2014 at 12:42
6

For those reading that are using Visual Studio 2008, not Visual Studio 2010 and are getting this error. The answers above did not help me in this situation, so I'm sharing my experience.

If you're debugging an IIS Web application in Visual Studio 2008 by attaching to the w3wp.exe process rather than using the ASP.NET Development Server for debugging (start with debugging), this might be your issue:

Visual Studio might be still referencing a symbol file (file used during debugging) from your dll from an IIS process that is out of date. And that symbol file has been recreated by a .NET source code recompile but the IIS process is still referencing the old symbol file.

To fix:

Just stop debugging in Visual Studio, restart the web application, and re-attach to the process. Then the breakpoints should turn from yellow (when you see this error) to red again.

========================

More things to try (found new situation today):

Do each bullet in the link below ONE AT A TIME, but repeat my steps below with each one you try.

http://carnotaurus.philipcarney.com/post/4130422114/visual-studio-debugging-issue-with-files-of-the-same

1.) Stop debugging (press red square icon) in Visual Studio
2.) Clean Solution
3.) Build Solution
4.) [INSERT BULLET INSTRUCTION HERE]
5.) Tools > Attach to Process (or start with debugging)
6.) Start the program that you're attaching to, and run it such that your code will get hit

6 explained:

If attaching to nunit.exe, then open NUnit and run a test so your breakpoint will be hit

If attaching to w3wp.exe (IIS site), then open your site in the browser and go to the page that will hit your breakpoint

EDIT:

Today I noticed that if you try debugging on a project that is not set as the start-up project, it will show this. When you attach to your w3wp.exe process, it thinks its debugging on the project that is set as the start-up project. To resolve, just right click the web application project, and choose "Set As Start Up Project". Then try re-attaching to your process.

2
  • Feel free to upvote the answer if it was helpful. :-) I'll show you what upvoting does. Commented Apr 13, 2015 at 19:06
  • I upvote to your answer as it was helpful. I tried another ways but your's was the one which pulled me out. Thanks +1.
    – Zaker
    Commented Apr 13, 2015 at 19:25
5

The scenario is this: a particular project is your start up project (e.g. has the Main method). That project is referencing other projects in your solution. Breakpoints in the other projects aren't getting hit.

Quick solution: when you build your solution, look in the Build output path (usually bin\Debug) for the start up project. Look at the DLL and PDB files for the projects you're referencing. Make sure their last modified date is the date you last built your solution. If they are not, then copy them from the Build output path for each project into your start up projects Build output path. For example:

Project A has Main. It references Project B. Your breakpoints aren't being hit in Project B. Copy the DLL and PDB file from Project B's Build output path to Project A's Build output path. Then run your solution. The break point will now be hit.

Now you need to figure out why Project A isn't copying over Project B's DLL and PDB file. The answers here cover most scenarios. One scenario not touched is making sure your projects and solution are binded to TFS properly. I had some projects binded and some not binded correctly. That caused the issue for me. Once I fixed that, the problem went away and I no longer had to copy over the DLL and PDB files.

1
  • Your paragraph 2 fixed my problem. One of the projects in the solution was in a different bin directory than the bin directory of the startup dll.
    – BobRodes
    Commented Nov 20, 2014 at 20:59
5

To fix this issue in Web.config I just had to add debug="true"

  <system.web>
    <compilation targetFramework="4.0" debug="true">

What helped me to find this solution has been looking at the Modules windows while debugging and saw that for my ASP.NET DLLs loaded I had: Binary was not built with debug information.

4

The solutions to the same problem in my case was the following combination of steps:

  1. Solution --> Properties Select multiple startup projects select Start action on the projects you need to debug.
  2. Removed the service from Service References and clean up the solution.
  3. Rebuild the service project
  4. Added it back to the Service References
  5. Clean up the solution and rebuild it.
4

I had the same problem but in VS2013 for a Web App. For me, the answer was to update the Build Configuration for the solution:-

  1. Right-click on the Solution and choose Properties
  2. Select the Debug configuration
  3. Select "Configuration" under "Configuration Properties" in the trivet
  4. Check on the "Build" box for each project you want to debug

Once I did this, all of my breakpoints started working.

1
  • This worked for me, but I also had to change all my projects from Release to Debug within the Configuration column. Commented Feb 25, 2016 at 20:06
2

Okay- here we go:

(In a "silverlight app": please check first that silverlight is checked in "web" in your server project "properties"- If that didnt solve it then try this beneath)

On first time do: run this first: devenv.exe /ResetSettings and 1: In top menu click on debug tag 2: click options and settings 3: In "debugging" and under "general" find "enable .net framework source stepping" 4: Tick the box. 5: And now all the symbols will be downloaded and reconfigured :)

If it happens again after the above just clear the folder where the symbols are:

1: In top menu click on debug tag 2: click options and settings 3: In "debugging" and under "symbols" find the button "empty symbol cache" and click it.

2

Open the Web Application url from the Browser and then in the VS.Net IDE use Tools-->AttachtoProcess

then attach to aspnet_wp.exe.

The Debugger will start working

2

I had to manually uninstall all instances of the .dll from the registry, and all instances of the .dll from my local drive. Uninstalled/reinstalled my app and now im hitting breakpoints! Wasted a half a day doing this :(.

2

I tried renaming the .pdb file in obj\debug folder and did a clean solution and rebuild.
It created a new .pdb file and I was able to hit breakpoints correctly.

2

I had the same problem - lost lot's of time trying to get debugging working in Visual Studio.

It ended up being Nuget - I had 3 versions of Newtonsoft.Json (across 7 C# projects). The solution would compile but wasn't debuggable.

I fixed the issue by running the following in Nuget's Package Manager Console:

PM> Update-Package Newtonsoft.Json

2

For my WPF app, I deleted the application folder, did "Get Latest" from source control again, and rebuilt. All breakpoints working great now.

1

Try to set Silverlight Application Project as as a startup project: right click on project -> 'Set As Startup project. Then press F5 and see if you can catch breakpoints...

Try to delete browsing/temp data in your browser each time You make changes to silverlight application

0
1

Another anecdote which might be useful-

I encountered this problem when one of my projects was using file references from a Release output folder. When the build results were placed in a Goods folder, these Release dlls were overwriting the Debug dlls.

The solution was to make sure in the csproj file, my reference's HintPath was

<HintPath>..\..\Core\Goods\$(Configuration)\MyFramework.dll</HintPath>

and not

<HintPath>..\..\Core\Goods\Release\MyFramework.dll</HintPath>

1

I had this very issue when at a client where - for each application solution - they copied most shared assemblies to a "References" folder, then added them to the solution both as "Solution items" and as a "Project" within the solution.

Not sure yet why, but some of them were debuggable, some not, even though in the References settings for the assemblies the correct full paths were specified.

This unpredictable behaviour alomst drove me mad :)

I solved this by removing all the assemblies from the "References" folder for which there were projects with source code, and keeping very good track of version information for shared assemblies.

1

I had a similar issue except my problem was silly - I had 2 instances of the built-in web server running under 2 different ports AND I had my project -> properties -> web -> "Start URL" pointing to a fixed port but the web app was not actually running under that port. So my browser was being redirected to the "Start URL" which referred to 1539 but the code/debug instance was running under port 50803.

I changed the builtin web server to run under a fixed port and adjusted my "Start URL" to use that port as well. project -> properties -> web -> "Servers" section -> "Use Visual Studio Development Server" -> specific port

Not the answer you're looking for? Browse other questions tagged or ask your own question.