IDistributedCache Missing Method Exception



Hi, I’m trying to use the dotnet core distributed cache implementation,, and I’m hitting a missing method exception.

 Exception has occurred: CLR/System.MissingMethodException
An exception of type 'System.MissingMethodException' occurred in TravelGuard.WebApi.dll but was not handled in user code: 'Method not found: 'System.Threading.Tasks.Task`1<Byte[]> Microsoft.Extensions.Caching.Distributed.IDistributedCache.GetAsync(System.String)'.'
   at Couchbase.Extensions.Caching.CouchbaseCacheServiceCollectionExtensions.AddDistributedCouchbaseCache(IServiceCollection services, Action`1 setupAction)
   at TravelGuard.WebApi.Startup.ConfigureServices(IServiceCollection services) in c:\dev\TravelGuard\src\TravelGuard.WebApi\Startup.cs:line 61

I can see that the method was implemented, back in January, here:
The nuget package was published in March, so I assume it should have this method, but maybe it was using a different branch?

This is the code that I’m using in the ConfigureServices(IServiceCollection services) method in my Startup.cs

services.AddDistributedCouchbaseCache(opt =>
    opt.Configuration = new ClientConfiguration
        Servers = new List<Uri>
        { new Uri(Configuration["CouchbaseConfig:host"])}

    opt.BucketName = Configuration["CouchbaseConfig:bucket"];
    opt.Bucket = ClusterHelper.GetBucket(opt.BucketName, Configuration["CouchbaseConfig:password"]);

Has anyone else had success with that nuget package? Any chance that we can get a new build published to nuget?


Hi @divinebovine -

The Session and Caching projects has been merged into the Couchbase.Extensions project - they both now depend on Couchbase.Extensions.DependencyInjection, so the initialization has changed somewhat. A new beta of the Caching and Session was just published. Here is an example of the usage:

    public void ConfigureServices(IServiceCollection services)
        // Add framework services.
        //configure the Couchbase client
        services.AddCouchbase(opt =>
            opt.Servers = new List<Uri>
                new Uri("http://localhost:8091")

        //configure the cache to use the default bucket
        services.AddDistributedCouchbaseCache("default", opt=>{});

This doesn’t exactly answer your question, but I would start with updating to the newer beta1 and see if the issue still persists!




Thanks for the response @jmorris , unfortunately I have the same exception as seen below:

My csproj has the following references:

    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
     <PackageReference Include="Couchbase.Extensions.Caching" Version="1.0.0-beta1" />
     <PackageReference Include="Couchbase.Extensions.DependencyInjection" Version="1.0.1" />
     <PackageReference Include="CouchbaseNetClient" Version="2.4.7" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0-rc3" /> 

Am I doing something wrong here?



@divinebovine -

Hmm, can you create an issue and upload an example project? I’ll take a look at it and see if I can figure it out.




@divinebovine -

What OS are you using? I am wondering if its a platform specific difference in the IDistributedCache interface.



@jmorris, I’ll try to get an example project together a little later today. I’m using Windows Version 10.0.14393 Build 14393.


@jmorris, sorry for the delay. I did a simple webapi app with dotnet new and added in the couchbase references, and I still get the error. I’ve attached it for your convenience. (4.7 KB)


@divinebovine -

Your app is using .NET Core 2.0 - the current Cache and Session implementation only support .NET Core 1.0. It looks like perhaps the IDistributedCache interface may have changed for 2.0, thus the missing method exception.



@divinebovine -

Indeed, it looks like they added a CancellationToken parameter -
here is 1.0:

And here is 2.0:



Thank you @jmorris.

I know this is all still beta for both couchbase and dotnet core, but are there any plans to support 2.0 in the next few months? dotnet 2.0 is supposed to be released in the 3rd quarter so we’re targeting that for our project, and we’d like to use couchbase. If not, I understand, I’ll just have to make fallback plans.

Again, thanks for helping me troubleshoot this issue.


@divinebovine -

We do plan on supporting dotnet 2.0 and the goal was to have a release available when it goes RTM. That being said, I can’t guarantee an exact date for when this is going to happen.

The actual change seems to be pretty minor, it’s just an interface change for CancellationTokens. I’ll see if I can get a work-around for beta3.



Also starting to use .NET Core 2.0 now that it’s been released. Would love to be able to use Couchbase with it. (On Xamarin apps for iOS + Android).



Just wanted to touch base on this issue again. Are there any plans to address dotnet core 2.0 in the near term (~1-2 months)?



@divinebovine -

Yes! We are working on a 2.0 version as I write this! We hope to have something up on NuGet in the next couple of days.



@divinebovine @dd105 -

Updated versions of both Couchbase Session and Caching middle-ware with support for .NET Core are now available: