An exception with Loading assembly (lack of PublicKeyToken)

Topics: General discussion, Logging Application Block
Oct 1, 2007 at 2:01 AM
Edited Oct 1, 2007 at 2:04 AM
Hi, this my first attempt to evaluate Enterprise Library; my testing version is 3.1.0.0.

As I was testing the Logging library, an exception occurred:

System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, 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) (D:\working\MyProjects\WebSniffer\bin\Debug\WebHRSniffer.exe.config line 5)


I am aware that this is due to that the strong name of logging assembly built on my computerlacks the PublicKeyToken; the assembly I reference is:
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null

However, all the assembly name recorded in the App.config is <listeners>
<add source="Enterprise Library Logging" formatter="Text Formatter"
log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", which contains the PublicKeyToken.

How could I build the assembly with the key specified in the App.config? In other words, where is the key file?

Thanks a lot.
Ricky.
Oct 1, 2007 at 2:57 AM
Hi, guys.

This problem is due to my ignorance.

I refer to the wrong assemblies (built by my self, not the ones includes in the installed directory).

Ricky.
Oct 3, 2007 at 7:54 PM
I had this exact problem with the CS Logging QuickStart.
I had to change the references in the LoggingQuickStart project to get it to stop complaining and still be able to use the Enterprise Library Configuration tool.
Oct 4, 2007 at 7:45 AM


ttchipster wrote:
I had this exact problem with the CS Logging QuickStart.
I had to change the references in the LoggingQuickStart project to get it to stop complaining and still be able to use the Enterprise Library Configuration tool.


You can actually point the VS configuration editor to your choice of EntLib assemblies by changing the EnterpriseLibraryConfigurationSet property that appears in the Properties window when you select the solution root node. By default this is set to the strong-named binaries; however the QuickStart solutions are set to use non-strong-named versions.

For more information on this topic, check out this post.

Tom