Facing Problem in Enterprise Library-Caching Application Block+WCSF
Yesterday i have wasted[or invested] my whole day in solving the error…hoohhh..
What i want to do?
I want to use Caching Application Block with WCSF. means when user clicks on submit i have to Cache that page using CAB of MEL. it seems simple but i am facing problem in implementing it.
Problem I was facing
When i calls CacheManager _cacheManager = CacheFactory.GetCacheManager();
it gives me error. I have pasted stack trace here.
Stack Trace is as under:
Could not load file or assembly ‘Microsoft.Practices.EnterpriseLibrary.Common, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
System.TypeInitializationException was unhandled by user code
Message=”The type initializer for ‘Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory’ threw an exception.”
at Consensus.Net.Framework.Common.Caching.Cache.SetCache(String key, Object value) in C:\Latest Poc [Working Folder]\Consensus\Source\Consensus.Net.Framework\Consensus.Net.Framework\Caching\Cache.cs:line 38
at Consensus.Net.Web.Customer.CustomerController.cachepage(Booker booker) in C:\Latest Poc [Working Folder]\Consensus\UI\Consensus.Net.Web\Customer\CustomerController.cs:line 69
at Consensus.Net.Web.Customer.Views.DefaultViewPresenter.CachePage() in C:\Latest Poc [Working Folder]\Consensus\UI\Consensus.Net.Web\Customer\Views\DefaultViewPresenter.cs:line 64
at Customer_Default.btnSubmit_Click(Object sender, EventArgs e) in c:\Latest Poc [Working Folder]\Consensus\UI\Consensus.Net.Web\WebSites\DevelopmentWebsite\Customer\Default.aspx.cs:line 138
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I have searched on google and blog also…But i am unable to find it out. and no help on codeplex also.. i have invested almost one day for it and i don’t want that you people also waste for the same problem
So here’s the solution:
Solution may look so simple but it is working fine and taken much of my time so its most precious for me.
Just add Microsoft.Practices.EnterpriseLibrary.Common.dll(i have it at “C:\Program Files\Microsoft Enterprise Library 3.1 – May 2007\Bin”) Version: 220.127.116.11 to GAC[if you don’t know how to add it refer below step or Add it..].
Adding An Assembly to GAC
- Click the Assembly Cache node of the console tree. Alternately, you can click the Manage the Assembly Cache link in the pane on the right.
- Click the View List of Assemblies in the Assembly Cache link in the pane on the right.Alternately, you can right-click the Assembly Cache node, point to View on the shortcut menu, and select Assemblies.
The tool displays all assemblies in the Global Assembly Cache in the pane on the right. The tool also displays all native image versions of assemblies in the cache. Native images are versions of assemblies that have been pre-compiled to native code using the Native Image Generator (Ngen.exe).
- To delete an assembly from the cache, right-click the assembly name in the pane on the right and choose Delete from the shortcut menu.
- To add an assembly to the cache, right-click the Assembly Cache node and choose Add from the shortcut menu. The tool displays the Add an Assembly dialog box. Navigate to the assembly to add.
That’s it .