thoughts on coding

July 2, 2007

Want to debug 3rd party libraries?

Filed under: Uncategorized — Frantisek @ 4:50 pm

When I’d like to use any technology I’d like to know it first and then use it. How to know all the specifics and details about any technology, 3rd party controls, etc. ? For sure, it’s good to read some introductions how to use it, what the technology, libraries are about but then? reading the blogs, articles, examples … but all of them are very hard to collect and summarize. I think the best technical documentation about any code is the code itself.

I had similar problem with ASP.NET databinding, datasources, etc. I read several books, nice blogs from different people, I used the tool Reflector to look at the source code. But what I missed was to debug the 3rd party code. Why? Because I wanted to run the code and have a look at the code in the runtime. Via Reflector I can look at the code in the design time but via debugger I can check all class and method variables in the runtime. Via debugger I can see the call – stack which is quite hard to explore in Reflector (mainly because of overriding and inheritance).

So let’s recapitulate the problem: debugging the 3rd party libraries (.Net libraries included)

I had a discussion with my colleaugue and he adviced me to use the symbols server from MS. They should be fine at least for MS pdbs but what about other 3rd party libs. But OK. I tried it.

Using the symbol server 

Very brief description how to set up the symbol server within Visual Studio .NET 2005 is at:  It looked very nice and I was quite lucky that I need just to set it up and I’ll be able to debug 3rd party libs immediatelly without problems.

So I set up the Visual Studio, run the program within debugger. I set the breakpoint too and ….

 Calls Stack view (using symbol server)

…..when I looked at the call stack and click to the Stack frame related to the 3rd party code,I get the following screen:  

 Dissassembled code(symbol server)

I’m sorry but I’m not assembler friend. Debugging the code via assembler code is for me unacceptable. I was quite disappointed but .. maybe I forgot to set some other property up in order the debugger to display me at least MS IL code.

So the story continues …

I tried to find a developer-friendly way to debug. I think when you don’t have the code but your would like to debug the code anyway then it’s necessary to debug the code via MS IL. So debugging of the 3rd libraries requires MS IL knowledge (I think if you woud like to be a good .Net specialist, you should be familiar with MS IL code, too).  Reading MS IL wasn’t any stopper for me so… so I asked myself how to get the MS IL code from any 3rd party library? Of course, via ILDASM tool. As you can think the solution will need a little bit (ildasm/ilasm)-ing. So let’s deep inside it ..

Let me explain the way how to do it on System.Web.dll assembly (because I wanted to explore databinding in ASP.NET v 2.0):

    0)copy system.web.dll to “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\PDBs” (PDBs is my custom folder)
    1)run Visual Studio Command Tool, go to previously created folder and run “ildasm system.web.dll /”
    2)then run “ilasm /debug /dll /output=System.Web.dll”
    3)now stop all processes which have loaded the reassembled assembly (hm, good word) system.web.dll: i.e. W3WP,Aspnet_state,VisualStudio2005
    4)now run “sn -Vr System.Web.dll” which will skips the string name verification for the specified assembly while installing the assembly into GAC
    5)now install the assembly into GAC: “gacutil -i system.web.dll”
    6) now clean PDBs folder and keep only PDBs and ILs files. (In our case there will be and System.Web.pdb) 
    7)now open Visual Studio .NET and set the Tools -> Options -> Debugging -> Symbols to include also the path C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\PDBs

That’s all folks. Now you can set the break-point into i.e. Page_Load event and go to the call stack view and double-click 3rd party frame view and ….

Call Stack (with IL installed) 

you will get the following screen:

Dissasembled using IL code installed

Ok, you can say .. hm, but I’d like to see C# code, too .. at least for looking at the compete method written in C# .. .I offer to you TestDriven.NET. Hm, do you ask what this word has common with debugging? It’s Reflector add-in into VS.NET 2005. So download it and install it and ..

 Reflector addin installed

… then you are able to jump directly to the C# code from the debugger.


I hope this will help you to become better specialist and especially to know much better the 3rd party code which is sometimes very important …

I hope you enjoy it and send me any feedback, comments and new ideas how to debug 3rd party libs better and easily.

Enjoy it!



  1. Hello,

    debugging can reveal how the code works, (unit) testing can reveal what the code does. The latter is usually more important. And the only important for the code that I cannot alter, I dare to say.

    It might be even quicker to write some unit test than to debug tons of foreign code.


    Comment by _St — July 4, 2007 @ 8:59 am

  2. Hi _St,

    the posting is mainly about how to debug 3rd party assemblies and I think your comment is about something else.

    Anyway, I’d like to see you writing unit tests for the data binding, ASP.NET controls, any 3rd party UI controls -> I think there are tons of books which teach you what the code does but … many times it’s demostrated on hello world apps … and when you work on real application and would like to find where is the problem then debugging can help you. Really, I’d like to see you writing the unit tests in such cases ;o). I think the unit tests should be deployed with the components but I dont think there are any unit tests deplayed with .Net framework or do you know?


    Comment by fknet — July 9, 2007 @ 4:37 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: