23

I am using Visual Studio 2013, .Net Framework 4.0, and C#.

I am trying to debug a file in my project. I have the project set to debug build in the project properties, with "optimize" unchecked. And yet, whenever I try to debug this project, it can't load the symbols. So I go to the modules window to load the symbols, and the dll has "Optimized" column set to "Yes", the "User Code" column set to "No", and the message "Binary was not built with debug information" in the Symbol Status column.

I have cleaned and rebuilt, reset iis, and manually cleaned out the temporary asp.net files numerous times, with no avail.

Anybody know how to solve this?

tuseau
  • 1,334
  • 4
  • 17
  • 37
  • I have the project set to debug build in the project properties - you mean you have active configuration set to Debug? – lavrik Feb 13 '14 at 14:34
  • With your reference to temporary asp.net files - is this some form of web project? If so, how is the `compilation` element set in the relevant web.config? – Damien_The_Unbeliever Feb 13 '14 at 14:38
  • @lavrik Yes, I have active configuration set to debug. – tuseau Feb 14 '14 at 10:55
  • @Damien_The_Unbeliever Yes, it's a web app. Sorry I should have said that. web.config compilation element has debug="true" – tuseau Feb 14 '14 at 10:56
  • For visual studio 2017 (and probably earlier) you have to set Debug Information Format on the C/C++ General page, *and* set GenerateDebugInfo to Generate Debug Information on the Linker tab. – M Katz Apr 27 '21 at 19:07

7 Answers7

51

If your project is already in Debug mode. Please check Advanced Build Settings Dialog Box in Build tab of project.

Make sure that Debug Info is not set to none enter image description here Reference:

Stackoverflow

MSDN

Community
  • 1
  • 1
Abdul Rauf
  • 5,798
  • 5
  • 50
  • 70
  • Note that the settings inside the Advanced button are **relative to the selected configuration**. Took me a minute to figure out that I was setting Advanced Build Settings for a configuration different than my active configuration. – madannes Sep 21 '16 at 22:17
2

For Visual Studio 2017 for Configuration Release or Debug you can create a pdb file for debug information like this:

  • Right click your project in Solution explorer and select "properties"
  • Select "Configuration Properties"
  • Select "Debugging"
  • in "Generate Debug Info" select "Yes (/DEBUG)"
  • in "Generate Program Database File" enter: $(OutDir)$(TargetName).pdb
JayS
  • 2,057
  • 24
  • 16
1

If you're having this problem and none of the other answers here worked, check solution -> Properties-> Configuration and make sure that your project is set to debug.

Tom Clelford
  • 691
  • 6
  • 8
1

If you're trying to debug native code (C++) from managed code (C#), make sure that your properties are set to Mixed instead of Native only.

  1. Right-click on your project and click Properties.
  2. Under the Debug tab, go to the Debugger type section and change the Application process to Mixed (Managed and Native).

(I followed the answer given here by Weston. Thanks Weston!)

Community
  • 1
  • 1
Christine Loh
  • 801
  • 6
  • 5
0

The dll you are trying to debug most probably is not being built in your solution. You need to locate where it is being built and obtain a debug version (or at least a release version with the pdb symbol file).

Grzenio
  • 35,875
  • 47
  • 158
  • 240
  • It's definitely being built. I can see it in the bin folder after building, and it's named after the main project. – tuseau Feb 14 '14 at 11:12
  • @tuseau, make sure the build is referencing the project (i.e. remove the reference, and add it back in) – Grzenio Feb 14 '14 at 11:14
  • the build is the project. It's a solution with 1 web app project, I publish it directly to iis and attach to process. – tuseau Feb 14 '14 at 11:29
  • 2
    And what is the publish profile? Does it also have Debug build mode? – lavrik Feb 14 '14 at 14:22
  • 1
    Aha! It was set to "Release" not "Debug" in the publish profile (pubxml) file. Thanks. – tuseau Feb 14 '14 at 14:56
  • If someone is facing this issue in debug mode then he should check that whether "Debug Info" a.k.a pdb file or symbols are not set to None in Advanced build setting of project. For more information, view my answer – Abdul Rauf Sep 18 '15 at 15:56
0

the way i fixed this is by setting the debug mode in two places

  1. solution > properties > configuration Properties > configuration ( select the project where the code lives and set the configuration to debug )

  2. right click the project you want to debug > properties > set the configuration to debug

clean , rebuild , you're good to go

hamza felix
  • 39
  • 1
  • 4
-2

For Visual Studio 2019, Right click your project in Solution explorer and select "properties" -> Select Compile -> click Advanced Compile options -> Set Generate debug info to Full. Then clean solution and Rebuild solution.