Click here to Skip to main content
12,699,492 members (34,813 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# .NET C#4.0
Hi friends,

Can i debug a reference dll library i.e., i am not having the source code of that library in my solution. I will just add the dll by Add reference.

I heard that if the dll is built by enabling debug mode and by the use of .pdb file, the debug to the reference dll code can be performed.

Posted 21-Nov-11 5:11am
Updated 23-Aug-16 21:05pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Without source code? What would be the use? Well, there could be some, but very little. The PDB alone won't help you.

If you don't have the source code, you cannot make a fix anyway. If you don't have the source code, you have reflected meta-data, but for debugging, you need to get inside the method and execute it line by line, and the body of a method is not a part of the meta-data, so what would you debug? In principle it's possible to debug on the decompiled code, but I don't think a standard debugger will do it. It can use disassembly, which is not the same as you will be debugging IL code instruction by instruction.

You can simply experiment with Visual Studio. Create two assemblies with all the debug options, referencing one by the other by the DLL name: When using "Add Reference", add it from the "Browse" tab, because it should build when you remove the source code of the referenced assembly. Physically remove that source code; renaming of the project directory will be enough. Check that the entry assembly still runs while calling some method from the referenced assembly, because it uses just the DLL file. Make sure a PDB is created and not deleted, as well as the DLL. Now for the important step: You need to close Visual Studio and load the referencing application again. Debug it and try to "Step Into" the method of the referenced assembly to be called: Set a break point at this call and run the application to stop at this break point and press F11. You will see: "There is not source code available for the current location", with the option "Show Disassembly". Do it: you will see the IL code, which you can debug stepwise. Not what you hoped for. And this is the case when you actually have source code and can

By the way, what is the situation when you don't have source code, but do have PDB. You can have it in the experiment shown above, but who will give you PDB file without the source? Again, does not seem to be a real-life situation.

Abhinav S 21-Nov-11 12:11pm
Clear answer. 5.
SAKryukov 21-Nov-11 12:13pm
Thank you, Abhinav.
Manfred R. Bihy 4-May-12 5:01am
Fixed some grammar quirks!
Otherwise a fine answer, 5+
SAKryukov 4-May-12 10:48am
Thank you very much for your help, Manfred.
VJ Reddy 4-May-12 12:55pm
Nice explanation. +5
SAKryukov 4-May-12 13:07pm
Thank you, VJ.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Absolutely possible. Check out my blog

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 24 Aug 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100