Generate PDB from .NET DLL file?
Asked Answered
D

5

32

I need something that can generate a PDB from a DLL file (C# .NET code), is there any free program to do that?

Dermatophyte answered 18/5, 2010 at 16:37 Comment(1)
In theory it could be done, since with a .net dll you can get the original source code (to within experimental error). The only missing piece is format of the PDB file, which is a closely guarded secret. Reflector can take a dll and turn it into a solution, where you can use Visual Studio to compile it and generate the PDB at the same time. There are you using Visual Studio to generate a PDB for you - since it knows the secret format.Mufti
M
0

You need the source code in order to generate a PDB.

Modify answered 18/5, 2010 at 16:38 Comment(5)
In other words: it's not possible to create a PDB when all you have is the DLL.Confection
Well, I can use Reflector to get the source, so what I need to get the PDB?Dermatophyte
Remember that you don't get the same source as the one used to compile the DLL. It's a nightmare if there are lambda expressions, iterators, ... not even to mention obfuscation. But suppose that you have some source code, you supply the /pdb option to the compiler (msdn.microsoft.com/en-US/library/ms228625(v=VS.80).aspx).Modify
@Dermatophyte Reflector Pro (the 15 day trial they give you) will do exactly this - it'll decompile an entire assembly and will build a PDB so that you can debug into it.Endaendall
A little bit misleading answer. @Endaendall is right, I've used this option in the past and it works absolutely well!Trickster
S
27

Actually you can do it also with dotPeek from 1.2 version onward.

Right click the assembly in Assembly Explorer, and select "Generate Pdb". It also has the option to generate files for referenced assemblies all at once.

enter image description here

Spectrogram answered 1/7, 2014 at 9:29 Comment(2)
if the assembly doesn't contain a debug directory, it will still work if you combine this solution with the previous answer (and remove the .il file before recreating the dll/exe)Defile
Is there a way to prevent it from generating so many subfolders?Levanter
G
26

Even you have no sources and code obfuscated, you can create pdb by recompile with ildasm and ilasm:

  • decompile assembly by ildasm: ildasm /out=assembly_name.il assembly_name.dll
  • complile with ilasm: ilasm assembly_name.il /dll /pdb
Guyette answered 10/10, 2013 at 8:43 Comment(1)
This is a decent option when combined with debuginfo.com/tools/chkmatch.html - However, the source stepping will be lines of IL, not c# or vb.net.Temperamental
M
14

PDB contains debug symbols related to DLL, and would normally be built together with the DLL. To enable generating pdb files go to project Properties, Build tab, Advanced... button and select in Debug Info field "pdb-only" or "full":

Visual Studio generate PDB

If you need to debug a thirdparty assembly without sources, then dotPeek and ReSharper will be extremely helpful having an option to generate PDB from DLL. In ReSharper, this can be done through ReSharper > Windows > Assembly Explorer by opening necessary assembly and clicking "Generate Pdb...":

Resharper Generate PDB

Morehead answered 6/1, 2011 at 9:19 Comment(0)
P
1

You can use ILSpy. This is the handy free app for disassembling and generating pdb for managed dll's.

Peekaboo answered 4/12, 2019 at 11:40 Comment(0)
M
0

You need the source code in order to generate a PDB.

Modify answered 18/5, 2010 at 16:38 Comment(5)
In other words: it's not possible to create a PDB when all you have is the DLL.Confection
Well, I can use Reflector to get the source, so what I need to get the PDB?Dermatophyte
Remember that you don't get the same source as the one used to compile the DLL. It's a nightmare if there are lambda expressions, iterators, ... not even to mention obfuscation. But suppose that you have some source code, you supply the /pdb option to the compiler (msdn.microsoft.com/en-US/library/ms228625(v=VS.80).aspx).Modify
@Dermatophyte Reflector Pro (the 15 day trial they give you) will do exactly this - it'll decompile an entire assembly and will build a PDB so that you can debug into it.Endaendall
A little bit misleading answer. @Endaendall is right, I've used this option in the past and it works absolutely well!Trickster

© 2022 - 2024 — McMap. All rights reserved.