Could not load file or assembly... HRESULT 0x80131040

Topics: Enterprise Library Core, General discussion, Logging Application Block
May 29, 2007 at 8:10 PM
Hi, are you guys familiar with the problem of configuring the application block with the configuration manager, and when the programs runs I get the exception: "Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)".
When I take of the publick token key from thie configuration it works.

I've recorded a repro of this issue, available over here:

Guy Burstein
May 30, 2007 at 4:55 PM
It typically means the assembly references in your configuration file are different from the assemblies you are referencing in the application. Hence the configuration file may be referencing EntLib 2.0 while the application is referencing EntLib 3.0.




David Hayden
Microsoft MVP C#
May 30, 2007 at 6:23 PM
Hi Guy - left a comment on your blog, but might as well copy it on this thread.

What you should do is right-click the Solution node in your solution explorer and choose properties. There is a property in the property editor that allow's you to specify the binaries compiled from your sources as the once that the integrated editor should use. The default is the signed assemblies from within your program files.

In your case this should be:

"EnterpriseLibraryConfigurationSet" = "EntLib3Src"

This is done because the Integrated editor allows you to use different copies of Enterprise Libraries binaries (signed by Microsoft, unsigned or signed with your own key) to be used.

May 31, 2007 at 3:17 AM
Tom Hollander's blog give some more detail on this problem
May 31, 2007 at 7:31 AM
Thank you all, Is did solve the problem.
I wish I had read Tom's post earlier :)