Click here to Skip to main content
Click here to Skip to main content
Go to top

Diagnosing assembly bind failures with Assembly Binding Log Viewer

, 19 Apr 2012
Rate this:
Please Sign up or sign in to vote.
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 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:

http://msdn.microsoft.com/en-us/library/e74a18c4%28v=vs.71%29.aspx http://msdn.microsoft.com/en-us/library/e74a18c4.aspx

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

My Tech World

United States United States
No Biography provided

Comments and Discussions

 
QuestionNot an article PinmvpAbhinav S18-Apr-12 19:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 19 Apr 2012
Article Copyright 2012 by My Tech World
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid