The current build operation failed: Object reference not set to an instance of an object

Topics: Caching Application Block
Mar 8, 2012 at 9:49 AM

In .net 4 website, I am making use of the Enterprise Library Caching assembly (Microsoft.Practices.EnterpriseLibrary.Caching.dll, version 4.0.0.0).

When I try to get one of my caches using the method

CacheFactory.GetCacheManager("MyCacheManager")

, the .net runtime throws the following exception:

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

Here is the full stack trace:

==============================================================================

at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing) at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, String id, IConfigurationSource configurationSource) at Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager(String cacheManagerName) at MyProduct.MyProductDAL.MyProductDAL..ctor(String connectionString) in C:\Users\Yosief.Kesete\Documents\Visual Studio 2010\Projects\MyProduct\MyProductDAL\MyProductDAL.cs:line 39

================================================================================

I am developing using VS 2010 on a 64-bit Windows 7 Professional PC. My site is hosted in IIS 7.5. I've also added references to the rest of the assemblies that go along with the caching assembly, such as :

Microsoft.Practices.EnterpriseLibrary.Common.dll v4.0.0.0

Microsoft.Practices.ObjectBuilder2.dll v2.1.0.0

Microsoft.Practices.Unity.dll v2.0.414.0

etc...

Can anyone please help me?

Mar 8, 2012 at 8:19 PM

Enterprise Library 4.0 uses Unity 1.1 so Microsoft.Practices.Unity.dll should have version 1.1.0.0 and not 2.0.414.0 (which is used by Enterprise Library V5).  Could that be the issue?

Also, Enterprise Library 4.0 has been retired so, if possible, it would be good to upgrade to a later version (4.1 or 5).

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Mar 9, 2012 at 9:02 AM
Edited Mar 9, 2012 at 9:05 AM

Hi Randy

I went with version 4.1 and after adding the caching settings in the web.config of my website, everything seems to be working. Originally, I had the caching settings in the app.config of a class project referenced by the website.

Thanks for the help.

Yosief Kesete