5

If I put my C# program exe in a text editor, I can find debug information in it:

enter image description here

How can I remove that?

EDIT: I dont care about the pdb file, i only care about that there is a path to the pdb file in the executable. This path contains my name (coincidence in this example), my question is how i can remove THAT Path from the executable, NOT how to remove the pdb file itself.

SinOfficial
  • 536
  • 5
  • 15
  • 1
    very funny... the compiler/linker does that. @SinOfficial, have a look at this: http://stackoverflow.com/questions/2371032/c-sharp-release-version-has-still-pdb-file – Cee McSharpface Jan 15 '17 at 12:13
  • How is debugging information "personal information"? – Camilo Terevinto Jan 15 '17 at 12:15
  • 9
    because it contains an absolute path revealing the user name of the profile that compiled it. which *is* worth consideration. – Cee McSharpface Jan 15 '17 at 12:16
  • 1
    The easiest way is to move your project to another location on the disk, and recompile. See also [how to clear PDB string in a release VC++ build](http://stackoverflow.com/q/32790375/33499). – wimh Jan 15 '17 at 12:41
  • Honestly, who keeps their source code in **My Documents** anyway? That's the first option I change –  Jan 15 '17 at 17:12
  • 2
    **This is not a duplicate**. OP want to know why and how to remove potentially sensitive information (pure coincidence in his example) from the exe. It took me a while too to realise what the OP wanted. Contrary to what it says above I never voted as duplicate. –  Jan 16 '17 at 01:44

1 Answers1

11

OK, so yours is actually a curious question because what you are asking for is really nothing you normally would be concerned about. PDB files are not "personal information" and neither is the path found in the .exe that points to the .PDB file. Your example is pure coincidence. Moving on...


Easiest fix Based on Best Practices

Don't keep your Visual Studio code inside your Windows User Profile Documents folder. Instead move it to one of the following

  • c:\development or better yet, a folder on a non-OS drive if you can
  • When you are ready to ship, ensure you build your code on a CI server. In this day and age there is no excuse for not using a CI server in the same way as you should be using source control

That will fix the coincidental username appearing in your exe. Unless of course you are running your build agent in your user context instead of a dedicated build account.

Also, I like to keep Documents for, well documents and not get polluted with code; Git or SVN caches. It just creates noise for real-time back-up apps like CrashPlan.

Alternative

Just build without debug information.

Consider this default debug build, note the path to the associated PDB File:

enter image description here

Release with No debug settings

enter image description here

Settings

enter image description here

Yours is a debug build which you can tell by the path to the PDB file, a file containing debug information about the application. Normally you don't deploy a debug build of your application.

Make a release build of your application. Release builds by default do not generate a .pdb file.

Also, .pdb files don't give away "source code" to avid readers if that is your fear. At most it may list the path to a file, but a filepath doesn't constitute source code content.

See also:

Community
  • 1
  • 1
  • I dont care about the pdb file... I care about the name in the path. But your solution worked. thanks – SinOfficial Jan 15 '17 at 12:46
  • @MickyD hahaha pdb stands for personal information hahahah very funny. do you really think that i thought that? – SinOfficial Jan 15 '17 at 12:50
  • @SinOfficial No, but when you build with **Full info** or **.pdb** only in either **debug** or **release**, guess what - whilst the exe contains a full path to the .pdb file; the pdb file contains full paths to **all the original file paths to your source code when you compiled your app**. As **dlatikay** correctly points out, such a path is going to include in your case, your usename profile just out of **pure coincidence**. So there is that –  Jan 15 '17 at 17:00
  • You can also remove the path to the PDB file by including it in the EXE file: https://stackoverflow.com/a/73230666/9134997 – Michael Hutter Aug 04 '22 at 05:26
  • @MichaelHutter true, but for release builds who wants a huge .EXE file instead of deploying an _optional_ .PDB file? PDBs were designed for this reason. –  Aug 04 '22 at 05:59