I am trying to sort out a friends service. Basically it gets into error as soon as I start it in constructor. Here are the code fragments.
public class DefaultCacheManager : ICacheManager
{
private readonly Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager _cacheManager;
public DefaultCacheManager()
{
//Code blows here
_cacheManager = CacheFactory.GetCacheManager();
}
The error I get is below.
Unhandled Exception: System.TypeInitializationException: The type initializer for 'Test.TypeManagement' threw an exception. ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Test.DefaultCacheManager", name ="CacheManager".Exception occurred while: Calling constructor Test.DefaultCacheManager(). Exception is: TypeLoadException - Could not load type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer' from assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. ----------------------------------------------- At the time of the exception, the container was:
Resolving Test.DefaultCacheManager,CacheManager Calling constructor Test.DefaultCacheManager() ---> System.TypeLoadException: Could not load type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer' from assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.InnerGetCacheManager(String cacheManagerName) at Test.DefaultCacheManager..ctor() in c:\Test\CacheManager.cs:line 12 at lambda_method(Closure , IBuilderContext ) at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.<>c__DisplayClass1.b__0(IBuilderContext context) at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable1 resolverOverrides)
1 resolverOverrides) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides) at Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, String name, ResolverOverride[] overrides) at Test.TypeManagement.get_CacheManager() in c:\Test\TypeManagement.cs:line 56 at Test.TypeManagement..cctor() in c:\Test\TypeManagement.cs:line 36 --- End of inner exception stack trace --- at Test.TypeManagement.get_ServiceHost() at Test.ThreadManager.Start() in c:\Test\ThreadManager.cs:line 19 at Test.Program.Main(String[] args) in c:\Test\Program.cs:line 14
--- End of inner exception stack trace --- at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable
Any help and direction would be most welcomed.
Config
<configSections>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<cachingConfiguration defaultCacheManager="Cache Manager">
<cacheManagers>
<add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="Data Cache Storage" name="Cache Manager" />
</cacheManagers>
<backingStores>
<add databaseInstanceName="CachingStaging" partitionName="CS" encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Data Cache Storage" />
</backingStores>
</cachingConfiguration>