VahidN / EFSecondLevelCache.Core

Entity Framework Core Second Level Caching Library
Apache License 2.0
326 stars 51 forks source link

Does not have an implementation #29

Closed kotx closed 5 years ago

kotx commented 5 years ago

Summary of the issue

System.TypeLoadException: Method 'ExecuteAsync' in type 'EFSecondLevelCache.Core.EFCachedQueryProvider`1' from assembly 'EFSecondLevelCache.Core, Version=1.7.1.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

It seems that I would need an implementation, but your examples don't seem to have any, so I was curious.

Environment

The in-use version: 1.7.1
Operating system: Manjaro Linux
IDE: Jetbrains Rider

Example code/Steps to reproduce:

.AddEFSecondLevelCache()

                .AddSingleton(typeof(ICacheManager<>), typeof(BaseCacheManager<>))
                .AddSingleton(typeof(ICacheManagerConfiguration),
                    new ConfigurationBuilder()
                        .WithJsonSerializer()
                        .WithMicrosoftMemoryCacheHandle()
                        .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromMinutes(10))
                        .Build())
...
Services = ConfigureServices();
            EFServiceProvider.ApplicationServices = Services;
// BakaContext.cs
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using EFSecondLevelCache.Core;
using EFSecondLevelCache.Core.Contracts;

namespace BakaZero.Data
{
    public class BakaContext : DbContext
    {
        public BakaContext(DbContextOptions<BakaContext> options) : base(options)
        {        }

        public DbSet<BakaGuild> Guilds { get; set; }
        public DbSet<BakaUser> Users { get; set; }

        public override int SaveChanges()
        {
            ChangeTracker.DetectChanges();
            var changedEntityNames = this.GetChangedEntityNames();

            ChangeTracker.AutoDetectChangesEnabled = false; // for performance reasons, to avoid calling DetectChanges() again.
            var result = base.SaveChanges();
            ChangeTracker.AutoDetectChangesEnabled = true;

            this.GetService<IEFCacheServiceProvider>().InvalidateCacheDependencies(changedEntityNames);

            return result;
        }

        public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
        {
            ChangeTracker.DetectChanges();
            var changedEntityNames = this.GetChangedEntityNames();

            ChangeTracker.AutoDetectChangesEnabled = false; // for performance reasons, to avoid calling DetectChanges() again.
            var result = base.SaveChangesAsync(cancellationToken);
            ChangeTracker.AutoDetectChangesEnabled = true;

            this.GetService<IEFCacheServiceProvider>().InvalidateCacheDependencies(changedEntityNames);

            return result;
        }
    }
}

Output:

Exception message:

Command     Discord.Commands.CommandException: Error occurred executing "listprefix" for Kot#6386 in Kot and Friends/testing-2. ---> System.TypeLoadException: Method 'ExecuteAsync' in type 'EFSecondLevelCache.Core.EFCachedQueryProvider`1' from assembly 'EFSecondLevelCache.Core, Version=1.7.1.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

Full Stack trace:

  Command     Discord.Commands.CommandException: Error occurred executing "listprefix" for Kot#6386 in Kot and Friends/testing-2. ---> System.TypeLoadException: Method 'ExecuteAsync' in type 'EFSecondLevelCache.Core.EFCachedQueryProvider`1' from assembly 'EFSecondLevelCache.Core, Version=1.7.1.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
     at EFSecondLevelCache.Core.EFCachedDbSet`1..ctor(DbSet`1 query, String saltKey, EFCacheDebugInfo debugInfo, IEFCacheKeyProvider cacheKeyProvider, IEFCacheServiceProvider cacheServiceProvider)
     at EFSecondLevelCache.Core.EFCachedQueryExtensions.Cacheable[TType](DbSet`1 query, String saltKey, EFCacheDebugInfo debugInfo, IEFCacheKeyProvider cacheKeyProvider, IEFCacheServiceProvider cacheServiceProvider)
     at BakaZero.Modules.SettingsModule.PrefixesDisplay()
     at Discord.Commands.ModuleClassBuilder.<>c__DisplayClass6_0.<<BuildCommand>g__ExecuteCallback|0>d.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at Discord.Commands.CommandInfo.ExecuteInternalAsync(ICommandContext context, Object[] args, IServiceProvider services)
     --- End of inner exception stack trace ---

I'm a bit new to C#, so please be gentle :)

VahidN commented 5 years ago

Method not found usually means your project or projects in the solution are not using the latest dependencies. Try these steps:

kotx commented 5 years ago

Well VS just deleted my entire solution somehow, so I'll just reopen if that doesn't work in the future.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.