BucketAsync missing

All:

I’m just getting started with Couchbase. I believe it will work well with a new project, if I can get over some initial hurdles.

I have Couchbase server 6.6.x Community running on my Linode (Ubuntu 18.04) and have no problem accessing the web console. I added the travel-sample bucket for testing
I am following the Couchbase Install and Start tutorial. I created a .NET Core console application and added CouchbaseNetClient and Couchbase.ExtensionsDependencyInjection NuGet packages.

Here is my code so far:

    using System;
    using System.Diagnostics;
    using System.Runtime.InteropServices.ComTypes;
    using Couchbase;
    using Couchbase.Extensions;

    namespace CouchbaseTest01
   {
       class Program
       {
        static void Main(string[] args)
       {
           Connect();
        }

        static async void Connect()
        {
            var cluster = Cluster.ConnectAsync("http://myCouchbaseHostIP","cbTestUser","myPassword"); // connects ok

           //Here the tutorial shows
           //var bucket = await cluster.BucketAsync("bucket-name")  //
        }
    }
}

Problem is when I type var bucket=await cluster. there is no method called BucketAsync();
What am I doing wrong?

TIA for your help.
Norm

Hi @normschaeffer,

Welcome, and thanks for giving Couchbase a try!

I think the issue here is that you also need an await before Cluster.ConnectAsync(…), e.g.:

var cluster = await Cluster.ConnectAsync("http://myCouchbaseHostIP","cbTestUser","myPassword");

I often find myself forgetting awaits too :slight_smile:

I hope that works. If the tutorial you’re following doesn’t show this, please let me know where it is so I can get that corrected.

Also, you should be able to change your Main to be static async Task Main(...) because I think you’ll hit the same issue when you try to call Connect() from a non async Main.

2 Likes

Matthew:
Thanks for your speedy response … the tutorial is correct. I need to read more carefully :slight_smile:
I am now connecting and getting BucketAsync.

Now onto pulling data.
Thanks again.
Norm

1 Like