AsmSpy to the rescue

Have you ever need to update a .config file to add an assembly binding because your application it's trying to load a weird version of a specific dll and you don't know why?

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.3.0"/> </dependentAssembly> </assemblyBinding>

Recently in our company we have had to add a binding redirect for 'System.Web.Mvc' dll because it always tries to load an old version, in our case (and we are not alone) it was trying to load version 4.0.0.0 even when in our solution (and all the projects) we have references to version 5.2.3.0 (latests at the moment of writing).

So I started to hunt down why we needed to add that binding redirect I wanted to find the reason, somehow and something was obviously trying to load an incorrect version of that dll, fortunatelly for me that's when I found the AsmSpy tool.

AsmSpy is described in its github repository as

A simple command line tool to view assembly references.

You just need to download the zip filem, run a command line and it will list all the conflicts of dependencies but more importantly it will list who is referencing those dlls, see the image below it's awesome.

As you can see in the image above the 'System.Web.Mvc' dll version 4.0.0.0 is getting references by our beloved third party 'CodeEffects'.

There is nothing that I can do about that but at least I'm happy to answer why we have to add a assembly binding redirect to our configuration files.

TL;DR You gotta save this github project AsmSpy in your favorites because you don't know when it's going to save you a lot of headaches and confusions.

Disclaimer: I have nothing to do with AsmSpy github project or his author.

Happy debugging!