C# release version has still .pdb file

48,447

Solution 1

If you want to disable pdb file generation, you need to use the "Advanced build settings" dialog available in project properties after clicking the "Advanced..." button" located in the lower part of the Build tab.

Set Output - Debug info: to None for release build configuration and no pdb files will be generated.

Solution 2

The default is to generate PDBs for release builds as well. That is a feature and you shouldn't disable it. Generating PDBs means you can get more information when debugging. The performance of the code is not affected in any way by the presence of PDB files.

Solution 3

You don't have to ship the .PDBs with your release deployment, but they are useful to keep around - for example you can remotely debug the code running on a different machine using the PDBs on your machine to get the line numbers of where exceptions occur.

Without the use of the .PDBs, line numbers and file names are not included in stacktraces so it makes it much harder to debug them.

Solution 4

You control pdb / symbol generation in the project properties under Build -> Advanced... -> Debug info:. The options are:

  • none (no symbol information)
  • full (a .pdb will be produced, and some symbol information is embedded in the assembly)
  • pdb-only (a .pdb will be produced but the assembly is not impacted)

See http://msdn.microsoft.com/en-us/library/8cw0bt21%28VS.80%29.aspx for more information.

I strongly recommend that you choose the pdb-only option, not the none option as it still gives you some symbol information without affecting the assembly - you will probably find that this is the current setting you have on your release builds.

Solution 5

Having the compiler generate a .pdb file is not mutually exclusive to having it optimize the code.

For more info on this subject, read these blog entries.

Share:
48,447
Abruzzo Forte e Gentile
Author by

Abruzzo Forte e Gentile

Updated on July 05, 2022

Comments

  • Abruzzo Forte e Gentile
    Abruzzo Forte e Gentile almost 2 years

    I want to deploy the release version of my application done in C#.

    When I build using the Release config, I still can see that .pdb files are produced, meaning that my application can be still debugged. This also means that some debug information is present somewhere in my code, slowing it down a little bit.

    If this is true, how can I completely suppress any debug information produced in the binaries? Do you also know the reason of for having release .pdb? The Release configuration has the Optimize code checked, and only the TRACE constant is defined, not DEBUG.

    Thank you for assisting.

  • Justin
    Justin over 14 years
    Yes, but embedding debug info in the assembly can also have an impact on performance (according to Microsoft)
  • Abruzzo Forte e Gentile
    Abruzzo Forte e Gentile over 14 years
    Thanks! This was useful! I didn't realize that line number are not present in the StackTrace of each exception object!
  • Abruzzo Forte e Gentile
    Abruzzo Forte e Gentile over 14 years
    Hi Brian! Thanks! I was skeptical for this, but it seems that everyone agrees on that!
  • theJerm
    theJerm over 10 years
    So everyone agrees that the PDB files don't decrease performance? Has anyone ran any tests to confirm?
  • Brian Rasmussen
    Brian Rasmussen over 10 years
    @theJerm the app doesn't read the PDBs during run-time. So apart from the disk space they take up there's no overhead unless you're debugging.
  • dotNET
    dotNET over 7 years
    @BrianRasmussen: Are PDBs useful in reverse-engineering in any way? I'm obfuscating my release builds. Should I still generate PDBs in the output?
  • cowlinator
    cowlinator about 6 years
    You can also use MSBuild.exe YourProject.csproj /p:DebugSymbols=false /p:DebugType=None
  • Jamie Nicholl-Shelley
    Jamie Nicholl-Shelley almost 6 years
    Sorry but I have to disagree, the release build should be exactly that : release, no debugging and not debugging run-time dependencies.
  • Jakub Míšek
    Jakub Míšek about 3 years
    unless you are releasing your commercial software of course ;-)