Vaibhav Gaikwad
Microsoft .NET developer
Bla Code! Bla Code!

Remove full path of PDB file from C# dll or exe. (/pdbaltpath in c#)

Monday, December 12, 2011 4:01 AM

I came across a challenge last week, wherein I was asked to remove the path information from the dll files which were build inside my project.

For those who don’t have an idea about what I am talking about, here is a quick introduction. The dll/exe files which are build by Visual Studio contains the Win32 PE header information, and this is true for all the dll and exe on Win32 platforms. Read about it at (

To check the headers in your dll/exe files you can use the dumpbin tool.


So you can see the full path of the PDB file is embedded inside the DLL file, which is the point of concern as you might not want to expose private information in your releases. Fortunately this can be avoided by using the linker argument “/PDBALTPATH:%_PDB%” which just embeds the filename of PDB instead of full path. Unfortunately, this is true only for VC/C++ and there is no way to use this method when you are building C# assemblies.

So I started reading the internet to find a quick hack for it. Some suggested rebase.exe and some suggested “binplace.exe”. Binplace comes with Microsoft DDK. Nothing worked for me, and hence you are reading this post Smile

I decided to strip out the file path information myself, and so started reading on PE header format. I saw some interesting article already written on the same problem.

I used the code provided in above article and tweaked it to make it more user friendly. My code is variant of DebugDir.cpp written by  Oleg Starodumov.

I renamed the build to have a output called “DebugInfo.exe” and which has 2 arguments.

Usage of DebugInfo.exe:

1. Just to list the debug directories

c:\DebugInfo {filename.(exe|pdb)}


2. To remove complete PDB file information

c:\DebugInfo {filename.(exe|pdb)} clean


3. To remove just the path information of PDB and retain the filename

c:\DebugInfo {filename.(exe|pdb)} clean-path


You can verify the headers again using dumpbin.exe. Find the source code from the SourceForge site listed below. It is compiled and build using Visual Studio 2010 (VC++ Win32 Console application), add imagehlp.lib to your linker.



Have fun!!!

-Vaibhav Gaikwad


# re: Remove full path of PDB file from C# dll or exe. (/pdbaltpath in c#)

Not 100% sure but probably pdbstr from Debugging Tools for Windows can do the same 12/14/2011 3:46 PM | Michael

# re: Remove full path of PDB file from C# dll or exe. (/pdbaltpath in c#)

You can usually use binplace.exe to achieve something similar. 1/18/2014 11:36 AM | LuckyLuke

# re: Remove full path of PDB file from C# dll or exe. (/pdbaltpath in c#)

Very cool! 5/24/2017 5:46 AM | auser

# re: Remove full path of PDB file from C# dll or exe. (/pdbaltpath in c#)

The option "clean-path" does NOT remove the path from the assembly. Opening the resulting file in a hex editor you see that it just overwrites the beginning of the string with the filename and a NUL, the remaining full path with private information is kept. Only "clean" works. 9/16/2017 1:44 AM | dj

Post a comment