3

I'm trying to understand why I get the "The breakpoint will not currently be hit. No symbols have been loaded for this document" message, when try to debug my web site application (note: no web application, in case it matters)

So far I found out that the pdb (project debug database) file is as important as the source code, and it should appear in the bin folder, but for whatever reason the file is missing, just some dll's are placed there, actually there is no pdb file in the entire directory.

My first question is: There should be a pdb file regardless whatever the kind of project that is being developing. Correct?

Second question: How can I re-create that file again, or what steps needs to be done in order to debug the project again?

Somebody
  • 2,667
  • 14
  • 60
  • 100

6 Answers6

7

You have to have compilable code to get the pdb. It sounds like you do.

Usually what is happening is that you have setup your build to be "Release" instead of "Debug".

http://msdn.microsoft.com/en-us/library/wx0123s5.aspx

If you are creating a web application, your configuration files might also have a "Retail" setting. If set to true, you are always in "Release" mode, even if it says otherwise in your build configuration.

http://msdn.microsoft.com/en-us/library/ms228298(v=vs.80).aspx

Thomas Langston
  • 3,743
  • 1
  • 25
  • 41
  • Updated answer with another potential solution. – Thomas Langston Jan 20 '12 at 21:56
  • the Release mode still generates pdb files – Adrian Iftode Jan 20 '12 at 21:56
  • @AdrianIftode Sometimes, yes. Sometimes, no. http://stackoverflow.com/questions/291214/why-does-vs-2008-create-pdbs-for-some-release-projects-but-not-others – Thomas Langston Jan 20 '12 at 21:57
  • True, thanks. There is also the compilation section in the web.config file were compilation options can be set. It is for the generated dll(s) by ASP .Net for the aspx and ascx files. In case there are some – Adrian Iftode Jan 20 '12 at 22:04
  • @ThomasLangston regarding your second advice, I could'nt find any deployment retail="true", and is false by default. So I think that's not the case here. – Somebody Jan 20 '12 at 22:06
  • Also the compilation section is considered when the project is Web Site and not Web Application Project. – Adrian Iftode Jan 20 '12 at 22:06
  • Check the compilation section and the compilers section. Should look like and check if the compilerOptions attribute (which is not in this section, but in compilers section) is set. – Adrian Iftode Jan 20 '12 at 22:12
  • 2
    In the Web Site case the code behind files are compiled by ASP .Net not by you with Visual Studio, so there are no dll and pdb files in bin folder, these files are managed by ASP .Net when the site is "online". Bin folder can contain other dll and pdb files though. – Adrian Iftode Jan 20 '12 at 22:16
  • hummm interesting observation @AdrianIftode, but I'm still with no luck :( everything seems to be ok, could be something with the IIS ? – Somebody Jan 20 '12 at 22:28
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/6907/discussion-between-somebody-and-adrian-iftode) – Somebody Jan 20 '12 at 22:33
5

Couple of things I do to try to correct this problem:

  • Clear the temporary ASP.NET files (C:\Windows\Microsoft .NET\Framework{version}\Temporary ASP.NET files{site} (You will need to quit Visual Studio and any web browsers pointing to the development site)
  • Start Task Manager and right click the W3WP.EXE process, select SET AFFINITY and uncheck all but one CPU

Usually if I do this, then attach to the W3WP process to debug, the breakpoint will be filled in and I can step through my code.

Tim
  • 4,051
  • 10
  • 36
  • 60
  • Hi Tim, thanks for clarify, but I don't see the W3WP.EXE process running in the Task manager. And another question, now I can debug my website again like I said, but I still have some dlls that the symbols haven't loaded yet, Any ideas of how to fix this? – Somebody Jan 23 '12 at 20:06
  • I assume you're running through the VS debugger instead of attaching to a process. Try deleting your temporary ASP.NET files and running the debugger again. – Tim Jan 23 '12 at 20:51
  • I can't delete the temporary asp.net files even if I close VS, I have to log off and then log on again, does it sound weird to you? – Somebody Jan 23 '12 at 21:00
  • 1
    I've seen IIS lock the files on me too, not weird at all. (It drives me nuts at times) Try iisreset /stop, close any web browsers that are connected to the site, close VS, and try deleting the files again. After you're done remember to do an iisreset /start. – Tim Jan 23 '12 at 21:20
  • Thanks, hey you know what? in some pages the breakpoint works (appear filled) but in others don't, still the weird things :s – Somebody Jan 23 '12 at 21:27
  • I still have two dlls: InputsSanitizer.dll and Interop.CAPICOM.dll with no symbols loaded, but so far every breakpoint is filled, so thanks! – Somebody Jan 23 '12 at 21:50
2

To generate .pdb files in Release, you need to set your project's properties:

Compile\Advanced Compile Options\Generate Debug Info => 'pdb-only' or 'Full'

Package/Publish Web\Exclude generated debug symbols => untick this

Resource
  • 524
  • 4
  • 16
1

I just had this problem, and it turns out my web.config was set to debug=false.
Make sure that compilation debug=true in your web.config

<compilation defaultLanguage="vb" debug="true" batch="false" targetFramework="4.0">
  <assemblies>
    <!-- add references to gac assemblies here-->
  </assemblies>
</compilation>
csauve
  • 5,904
  • 9
  • 40
  • 50
  • Yep. Too bad every article on ASP.NET security says that this is a major security risk. Want no security and line numbers in your stack traces? Tough... – Roman Starkov Jul 07 '14 at 23:31
  • That only applies in a prod environment, and rightly so. – csauve Jul 08 '14 at 05:45
  • Maybe a bit out of place to discuss this in the comments, but why on earth is it right that you can't know the line numbers in your real-life, prod-environment unhandled exceptions? – Roman Starkov Jul 08 '14 at 10:13
0

Further to Resource's answer above, even though I am running debug versions, I had to set the Release version of the project to debug (in my case a NuGet package) to 'pdbonly' as well. I'm also using MyGet as a symbol server, but doing this I can also debug using local versions. I have the following setup:

Release versions uploaded to MyGet NuGet package server Debug versions uploaded to MyGet Symbol server

Symo
  • 466
  • 4
  • 16
0

In my quest for a solution to my problem I found this:

First, like Adrian Iftode said, in the Web site case, the code behind files are compiled by ASP .Net, not by the VS, so there are no dll and pdb files in bin folder.

  • So I delete all temporary files from: windows\Microsoft .NET\Framework\v2.0.50727\Temporary ASP.NET files\

which contains a folder for every project you have.

  • Delete all temporary files from iexplorer
  • In IIS properties for the project\Directory\Configuration\Debugging\ check both options below Debugging flags.

By doing all the above, I was able to debug my website again.

Somebody
  • 2,667
  • 14
  • 60
  • 100