Welcome to MSDN Blogs Sign in | Join | Help

Technical Weblog of Eric Charran

A Journal of My Technical Achievements and Challenges
Signing the Patterns and Practices Enterprise Library

We recently ran into an issue where a Windows Forms application was consuming the Enterprise Library's Caching and Exception Handling block.  The Windows Forms assembly was configured to be signed with a specified .snk file, which was the same .snk which we were planning to use to sign the Enterprise Library assemblies.  The first step was to open each project in the Enterprise Library and specify the .snk file.  We then had to update the assembly information to represent the internal hex private key which we extracted from the .snk.  See Tom Hollander's blog for specific instructions. 

Once the library was signed (the library projects, test projects and designer projects too) we then replaced the .dlls that were unsigned with the newly signed .dll files.  The challenge was that we were getting an assembly manifest exception from the Configuration Manager.

 

"An error occurred creating the configuration section handler for cachingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Caching, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

 

If you take note, the PublicKeyToken argument is null.  This is because the EntLib configuration tool was used prior to the signing of the assemblies.  Thus, this error was happening when the configuration manager tried to reconcile the signed referenced assembly for the EntLib in the project and the specification of the assembly in the app.config.  The above error is the result.  The quick fix is to place the public key token into the app.config for each specification of the EntLib .dll files.  This will cause the manifest and the app.config to agree and code execution to launch.  The long term fix is to place the signed assemblies for the Enterprise Library into the directory that the EntLib config tool lives.  Then when configuring a new application in this tool, the public key token will be written into the app.config. 

When manually doing this to remediate, use sn -t assemblyname.dll to extract the public key token.

 

Thanks to Tom Hollander who provided the solution!

Posted: Thursday, July 13, 2006 6:19 PM by echarran
Anonymous comments are disabled
Page view tracker