0

Trying to upgrade to EntLib from 3.1 to 5.0 and I'm running into an odd problem with caching. All our caching related unit tests are throwing:

failed: System.ArgumentException : Type does not provide a constructor taking a single parameter type of NameValueCollection

We're using the default CacheManger that comes with EntLib, works fine with v3, but when I look at the Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager class I can't see any related constructor in either 3.1 or 5.0 version?

[ConfigurationNameMapper(typeof(CacheManagerDataRetriever)), CustomFactory(typeof(CacheManagerCustomFactory))]
public class CacheManager : IDisposable
{
    // Methods
    internal CacheManager(Cache realCache, BackgroundScheduler scheduler, ExpirationPollTimer pollTimer)
    {
        this.realCache = realCache;
        this.scheduler = scheduler;
        this.pollTimer = pollTimer;
    }

Here's our configuration, which I created from the EntLib config tool:

<cachingConfiguration defaultCacheManager="Whatever">
  <cacheManagers>
     <add name="Whatever" 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="Null Storage" />
</cacheManagers>

I've had a look at the migration guide, but that didn't show anything up.

Are we now expected to create our own wrapper for the CacheManager?

si618
  • 16,580
  • 12
  • 67
  • 84

1 Answers1

1

Closer inspection of the stack trace revealed that it wasn't the cache manager throwing the exception, rather our custom IAuthorizationProvider.

Once I added the necessary constructor, most of our unit tests are passing. A few are still failing, but that appears to be due to differences in configuration and exception/error handling.

si618
  • 16,580
  • 12
  • 67
  • 84
  • A little bit late, but thanks, the clue you gave me to check the stacktrace helped me out and I found the source of the problem. :) – Jannik Feb 01 '17 at 12:40