Debugging in VS without the source code
Asked Answered
P

6

8

I need to debug some assemblies due to they throw exceptions. It's my assemblies but I don't have the source code of them. What I have is their pdb files.

Is there any way to debug that assemblies by Visual Studio?

--EDIT--

Of course, I also can disassembly them to get *.il files of them. Would it help me somehow?

Promoter answered 21/11, 2012 at 16:3 Comment(3)
What do you expect to be able to do with the information if you don't have the source? You can't fix anything...Conflux
It could also be the code calling the assemblies that don't call with the correct data. If the assemblies are not throwing sufficient information then you don't know what's going on. I would have liked to be able to trace assemblies sometimes...Gooey
the bit more explanation for pdb file msdn.microsoft.com/en-us/library/…Sublingual
A
4

This is exactly why I paid for Reflector. Need to debug someone else's assembly? It works perfectly.

Antonietta answered 21/11, 2012 at 16:15 Comment(0)
M
7

Actually there are a few ways to accomplish this:

  1. Use dnSpy - a free opensource .net debugger and assembly editor https://github.com/0xd4d/dnSpy
  2. Setup symbol server with dotPeek (also free) https://www.jetbrains.com/help/decompiler/Using_product_as_a_Symbol_Server.html
  3. Use Resharper decompiler to load symbols for external modules in your visual studio. I think this is the easiest way. I've described the whole process on my blog https://cezarypiatek.github.io/post/debug-without-sources-part-one/
Marquee answered 11/12, 2017 at 19:19 Comment(0)
A
4

This is exactly why I paid for Reflector. Need to debug someone else's assembly? It works perfectly.

Antonietta answered 21/11, 2012 at 16:15 Comment(0)
G
3

As far as I know, the PDB files are just pointers for debugging. That is, if you don't have the source code then the PDB files will only give you the stacktrace.

I don't know if Visual Studio can handle it, you might need to hook up manually to the process.

Gooey answered 21/11, 2012 at 16:13 Comment(2)
So what should I do with pdb files?Promoter
Your assemblies should end up in \bin\Debug or \bin\Release, so put the PDB files there too. When you debug your application with VS, you catch the Exceptions and look at the stack trace and inner exceptions. I had a logger that once used the PDB files get the stack, it took me time to understand why it was crashing in release without the PDB files.Gooey
C
1

Not exactly in visual studio, but I wrote in the past such a tool inside reflector, calle d Deblector. Is no longer mantained by me but have a look. Of course the debugging experience is not the same you can have in Visual Studio, but is sometimes enought to get you out of troubles.

Confocal answered 21/11, 2012 at 16:7 Comment(2)
Would it help me if I had il code of them? I mean debugging in VS.Promoter
@ALan Dert you debug at IL level, but you see the current source thanks to reflector, I said is not optimal, but better than nothing :)Confocal
M
1

Check out dotPeek: https://www.jetbrains.com/decompiler/

You can set this up as a symbol server inside visual studio to generate PDB files which allow you to debug. It is very easy to use and just as good as many of the paid products.

You can add libraries directly from nuget, or point to the DLL.

Magic answered 11/12, 2017 at 19:27 Comment(0)
C
0

dnSpy is the way to go if the program is a managed one, but you can open the .exe file in Visual Studio just as you would an .sln file.

You'll be able to debug and view the machine code.

For more information, see this blog post.

Churchman answered 19/9, 2024 at 16:26 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.