Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a third-party DLL in Visual Studio?

I am using a third-party DLL. For some particular cases, a function in the DLL is throwing an exception. Is it possible to debug the DLL in the Visual Studio?

After the answer from Andrew Rollings, I am able to view the code, but is there any easy way to debug through the code in Visual Studio?

like image 538
Biswanath Avatar asked Dec 08 '08 15:12

Biswanath


People also ask

How do I debug a DLL in Visual Studio?

Debug from the DLL project Set breakpoints in the DLL project. Right-click the DLL project and choose Set as Startup Project. Make sure the Solutions Configuration field is set to Debug. Press F5, click the green Start arrow, or select Debug > Start Debugging.

How do I debug an external EXE in Visual Studio?

Just use File/Open Project/Solution, select EXE file and Open it. Then select Debug/Start debugging. The other option is to run the EXE first and then Select Debug/Attach to process. Save this answer.


2 Answers

If the DLL is in a .NET language, you can decompile it using a tool like .NET Reflector and then debug against the source code.

Or you could ask the vendor if source code is available. That's probably the easiest way.

like image 78
Andrew Rollings Avatar answered Sep 20 '22 18:09

Andrew Rollings


Building on Andrew's answer, you just treat the decompiled source code as a new library within your project and set breakpoints in the source. Remove all references to the 3rd party DLL so that it is the decompiled code that is executing.

Other things:

  • You may be breaking the law by decompiling the code, or breaching a licensing agreement with the 3rd party vendor. Make sure to review this with someone.
  • You will want to make sure that you remove references to your decompiled version if you are shipping to other developers, or checking into a larger source tree. Easy to forget this!
like image 22
Brian Lyttle Avatar answered Sep 23 '22 18:09

Brian Lyttle