Click here to Skip to main content
15,860,972 members
Articles / All Topics

Diagnosing Assembly Bind Failures with Assembly Binding Log Viewer

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
19 Apr 2012CPOL2 min read 14.5K   1   2
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)".

Image 1

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).

Image 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.

Image 3

Fig 3: Assembly Viewer

Image 4

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionFormatting Pin
Wendelius19-Apr-12 1:45
mentorWendelius19-Apr-12 1:45 
Formatting is broken after the first image.
The need to optimize rises from a bad design.My articles[^]

QuestionNot an article Pin
Abhinav S18-Apr-12 19:42
Abhinav S18-Apr-12 19:42 

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

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