Error message: Microsoft.Practices.EnterpriseLibrary.Caching

Topics: Caching Application Block , Enterprise Library Core, Exception Handling Application Block, General discussion
May 7, 2010 at 6:26 AM

I was having the following error message:

The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory' threw an exception.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.ObjectBuilder2, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I am having the following refernces:

Microsoft.Practices.EnterpriseLibrary.Common, Microsoft.Practices.EnterpriseLibrary.Caching

The code is as follows:

[13:04:50] Shamima:   private static ICacheManager GetCacheManager()
Line 31:         {
Line 32:             return CacheFactory.GetCacheManager(cacheManagerName);
Line 33:         }
Line 34:     }
I have downloaded the 'Microsoft.Practices.ObjectBuilder2.dll.
Now I am having the following error message:

Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

How can I solve the error. Help Please.

Thanks

May 7, 2010 at 7:11 AM

How did you obtain your copy of the entlib assemblies?  Where did you download it? 

In your config, does your entlib assemblies have publickeytokens?  If yes, make sure that you have the strong-named version of the assemblies.  To check this, try if you can place those assemblies in GAC.  If you can't , then they're not strong-named.   You can obtain the strong-named versions by installing entlib, or if you already did, it's in the bin folder of the Enterprise Library installation folder.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
 entlib.support@avanade.com 

Jun 1, 2010 at 3:34 PM

Remove all existing caching refrences and add again

Microsoft.Practices.EnterpriseLibrary.Common.dll

Microsoft.Practices.EnterpriseLibrary.Caching.dll

If you decide to use the database as a caching store, you also need to add a reference to the Data Access Block (the Microsoft.Practices.EnterpriseLibrary.Caching.Data.dll).

Microsoft.Practices.ObjectBuilder2.dll

Let me know if does not help