Caching Application Block - Error

Topics: Caching Application Block
Dec 31, 2008 at 4:19 AM
Hi All,

I jus started to use the Enterprise Lib reg purposes like logging, Exception handling and Caching.  Over here I face a peculiar issue while working thro the Caching Block.

I have a windows application where in I referenced the following dlls from the C:\Program Files\Microsoft Enterprise Library 4.0 - May 2008\ Bin folder :

1. Microsoft.Practices.EnterpriseLibrary.Caching
2. Microsoft.Practices.EnterpriseLibrary.Caching.Database
3. Microsoft.Practices.EnterpriseLibrary.Common
4. Microsoft.Practices.EnterpriseLibrary.Data

I used the Enterprise Library Exe to create a new Caching application Block and I used the default values and saved them as test.config.

<

configuration>

 

<

configSections>

 

<

section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

 

</

configSections>

 

<

cachingConfiguration defaultCacheManager="Cache Manager">

 

<

cacheManagers>

 

<

add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"

 

 

numberToRemoveWhenScavenging="10" backingStoreName="Null Storage"

 

 

type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

name="Cache Manager" />

 

</

cacheManagers>

 

<

backingStores>

 

<

add encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

 

name="Null Storage" />

 

</

backingStores>

 

</

cachingConfiguration>

 

</

configuration>

 


I declared a class level object as follows:

 

ICacheManager myCache;

 


I instantiate the same as follows:

 

private void Form1_Load(object sender, EventArgs e)
{
   myCache =
CacheFactory.GetCacheManager();
}

When I try to run thro my application, i threw my the following error:   I error occured when the myCache gets instantiated.



The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager, null]) failed: Object reference not set to an instance of an object. (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy, index 0)

I believe the issue is related to the Dlls referenced.  Any help would be highly appreciated.  As am new to this Lib I am jus digging thro the same to find a solution.


Many Thanks
Krish

Dec 31, 2008 at 4:27 AM
Hi all,

I renamed my config file to App.config and it worked fine.

Many Thanks
Krish