System.Configuration.ConfigurationErrorsException: Unrecognized attribute 'symmetricInstance'

Topics: Caching Application Block , Cryptography Application Block
Feb 17, 2014 at 2:30 PM
Edited Feb 17, 2014 at 2:48 PM
I use this application architecture: an executable module and dll library. The library uses the Cache Manager.

var cache = EnterpriseLibraryContainer.Current.GetInstance<ICacheManager>();

This call throws System.Configuration.ConfigurationErrorsException with message "Unrecognized attribute 'symmetricInstance'. Note that attribute names are case-sensitive." . This exception occurs only when I use encryption cache. If I do not use encryption and remove section securityCryptographyConfiguration from app.config - is no exception. What could be the problem and how should I configure the Enterprise Library to use encryption cache into dll?

Visual Studio 2012 Update 4
.NET Framework 4.0
Enterprise Library 5.0

App.config:
<cachingConfiguration defaultCacheManager="Cache Manager">
<cacheManagers>
    <add name="Cache Manager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"
        numberToRemoveWhenScavenging="10" backingStoreName="Isolated Storage Cache Store" />
</cacheManagers>
<backingStores>
    <add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="NullBackingStore" />
    <add name="Isolated Storage Cache Store" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        encryptionProviderName="Symmetric Crypto Provider" partitionName="Test" />
</backingStores>
<encryptionProviders>
    <add name="Symmetric Crypto Provider" type="Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.SymmetricStorageEncryptionProvider, Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        symmetricInstance="TripleDESCryptoServiceProvider" />
</encryptionProviders>
</cachingConfiguration>
<securityCryptographyConfiguration>
<symmetricCryptoProviders>
<add name="TripleDESCryptoServiceProvider" type="Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.SymmetricAlgorithmProvider, Microsoft.Practices.EnterpriseLibrary.Security.Cryptography, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  algorithmType="System.Security.Cryptography.TripleDESCryptoServiceProvider, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
  protectedKeyFilename="C:\Users\*\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Key.key"
  protectedKeyProtectionScope="LocalMachine" />
</symmetricCryptoProviders>
Feb 18, 2014 at 2:51 PM
Can you check and ensure that the Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.dll assembly is deployed to the appropriate output directory. It probably isn't being deployed because it is only referenced in the configuration and not in the code.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Feb 19, 2014 at 12:56 PM
Thanks! Error occurs because, there is in DLL project a reference to the Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.dll , and there is no reference in the EXE project.
Marked as answer by Udakhin on 2/19/2014 at 4:57 AM