Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Diagnosing Assembly Bind Failures with Assembly Binding Log Viewer

0.00/5 (No votes)
19 Apr 2012 1  
The Assembly Binding Log Viewer provides the information on why an assembly can't be located by the .NET Framework.

Background

We were defining custom tasks for MSBuild to call the XsltCompiler executable to generate an assembly - Chocolate.Cake.dll. But I kept getting a runtime error saying that "Could not load file or assembly 'Chocolate.Cake' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)".

Fig 1

I tried to clean build everything to ensure that an older version is not being picked up. No luck for me. I was wondering whether an older assembly was getting bound. I realized the best option to see why this binding was failing by using the Assembly Binding Log Viewer.

Assembly Binding Log Viewer

The Assembly Binding Log Viewer provides the information on why an assembly can't be located by the .NET Framework. It's installed with Visual Studio and with the Windows SDK.

To see the details, I had to run the utility with admin rights (Fig 2).

Fig 2

I clicked Settings, and selected the Log bind failures to disk radio option. After refreshing, as seen in snapshot 3, I could see an entry for my Chocolate.Cake assembly, confirming the failure.

Fig 3: Assembly Viewer

Fig 5: Log Contents

In my case, I viewed the log, and for the scenario described in the background, I noticed that an attempt was made to find the Chocolate.Cake.dll.DLL! Turns out that when using MSBuild for the custom task, in my build proj file, my input parameter of assembly name also incorrectly included an extension of DLL. I had to change this assembly name to Chocolate.Cake from Chocolate.Cake.dll and everything worked fine after this. 

You can obviously customize where the logs can be saved, etc. Additional details can be found here.

Conclusion

This has been a very brief introduction to a very useful utility which can help in diagnosing why an assembly bind failure is occurring.

References

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here