Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .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.
 
Thanks,
MSK
Posted 21-Nov-11 4:11am

1 solution

Rate this: bad
good
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.
 
—SA
  Permalink  
v2
Comments
Abhinav S at 21-Nov-11 12:11pm
   
Clear answer. 5.
SAKryukov at 21-Nov-11 12:13pm
   
Thank you, Abhinav.
--SA
Manfred R. Bihy at 4-May-12 5:01am
   
Fixed some grammar quirks!
Otherwise a fine answer, 5+
SAKryukov at 4-May-12 10:48am
   
Thank you very much for your help, Manfred.
--SA
VJ Reddy at 4-May-12 12:55pm
   
Nice explanation. +5
SAKryukov at 4-May-12 13:07pm
   
Thank you, VJ.
--SA

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

  Print Answers RSS
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 4 May 2012
Copyright © CodeProject, 1999-2014
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