Error With Caching using WCF

Oct 15, 2010 at 1:36 PM

Hi,

I have a WCF service that runs fine and produces the expected result when run through Visual Studio 2010, however if I use this through a console application or host through a windows service i get the following error.

{"The current type, Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager, is an interface and cannot be constructed. Are you missing a type mapping?"}

 

Here are the relevent lines out of the config

<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" />

  

	<cachingConfiguration defaultCacheManager="vwcache">
		<cacheManagers>
			<add name="vwcache" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="NullBackingStore"/>
		</cacheManagers>
		<backingStores>
			<add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="NullBackingStore"/>
		</backingStores>
	</cachingConfiguration>

This is falling over when calling the following from my service

stockReconciliation.LSP = LSPDAL.Get(stockReconciliation.LSP);
And here is the Relevent part of the LSPDAL class
    public partial class LSPDAL
    {
                
        
        private static ICacheManager _lspCache = CacheFactory.GetCacheManager();
        
        private static List<LSP> _lspList
        {
            get { return (List<LSP>)_lspCache.GetData("lspList"); }
            set { _lspCache.Add("lspList", value, CacheItemPriority.Normal, null, new SlidingTime(TimeSpan.FromMinutes(5))); }
        }

        private static LSP Get(int ID = 0, string Name = "")
        {
            LSP lsp = null;

            if (_lspList == null) _lspList = GetList();

            if (ID > 0)
            {
                lsp = _lspList.Find(delegate(LSP dlsp)
                {
                    return dlsp.ID == ID;
                });
            }
            else if (!String.IsNullOrEmpty(Name))
            {
                lsp = _lspList.Find(delegate(LSP dlsp)
                {
                    return string.Equals(dlsp.Name, Name, StringComparison.CurrentCultureIgnoreCase);
                });
            }

            return lsp;
        }

 

Does anyone have any ideas?

Oct 16, 2010 at 4:51 AM

Is your cachingConfiguration section defined in the app.config of your console/windows service project? 

How about if you pass "vwcache" string in the call to GetCacheManager?  Does it run successfully?

 

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

Oct 25, 2010 at 1:18 PM

Thanks for that,

This was the problem. I had the information in the Service Project itself but not in the Windows Service config. This now works successfully.

David Morgan
Business Solutions Developer

Adare
Unit 1, Trade Link
Western Ave
West Thurrock

Essex
RM20 3FJ


T +44 (0) 1708 529707
M +44 (0) 7971 134809

david.morgan@adare.com
www.adare.com

From: David Morgan
Sent: 25 October 2010 14:17
To: 'entlib@discussions.codeplex.com'
Subject: [entlib:231038]

Thanks for that,

This was the problem. I had the information in the Service Project itself but not in the Windows Service config. This now works successfully.

David Morgan
Business Solutions Developer

Adare
Unit 1,
Trade Link
Western Ave
West
Thurrock
Essex
RM20 3FJ


T +44 (0) 1708 529707
M +44 (0) 7971 134809

david.morgan@adare.com
www.adare.com

Adare... enabling you to communicate with your audience in the most effective and inspiring way.

DISCLAIMER: This e-mail contains proprietary information some or all of which may be legally privileged. It is for the intended recipient only. If an addressing or transmission error has misdirected this e-mail, please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print or rely on this e-mail. Adare International Limited Registered in England and Wales. Registration No. 01610897, 1 Meridian South, Meridian Business Park, Leicester LE19 1WY, UK.

Please consider the environment before printing this email.

Apr 10, 2014 at 1:11 PM
Hi David,

Can you please share what you had to do to fix the problem ?

Onkar