Unable to get key from specific bucket

I’m using the CouchBase.NetClient 2.1 and I can create a Cluster Manager to list all the buckets; however, as soon as I try to retrieve a specific object by the key I get an error the reads, “Operation is not valid due to the current state of the object.”.

I’m also a bit confused as the previous versions (1.x), I provided the Administrator username and password in the web.config, but there doesn’t seem to be a place for that in the new version. Additionally, there is no password on each Memcached bucket, but they’re on dedicated ports. For simplicity sake, right now I’m just trying to access one bucket: global.

I’m running Version: 3.0.1 Community Edition (build-1444).

Here’s what the web.config looks like:

<couchbaseClients>
  <couchbase>
    <servers>
      <add uri="http://servername:8091/pools" />
    </servers>
    <buckets>
      <add name="global" password="" useSsl="false"  />
    </buckets>
  </couchbase>
</couchbaseClients>

So, doing the following lists all the buckets as expected:

using (var cluster = new Cluster("couchbaseClients/couchbase"))
{
    var cm = cluster.CreateManager("Administrator", "password");
    return cm.ListBuckets();
}

But, retrieving a key doesn’t work:

using (var cluster = new Cluster("couchbaseClients/couchbase"))
{
    var cacheBucket = cluster.OpenBucket("global");
    return cacheBucket.Get<dynamic>(cacheKey);
} 

I feel like I’m missing something really simple. Any idea what I’m getting wrong here?

You try using the actual type of the instance instead of ‘dynamic’?

internal T GetInstance(string cacheKey) 
{
    using (var cluster = new Cluster("couchbaseClients/couchbase"))
    {
         var cacheBucket = cluster.OpenBucket("global");
         return cacheBucket.Get<T>(cacheKey);
    }
}

I have and I’ve even tried to set a basic string entry and it fails on the insert with the same error (Operation is not valid due to the current state of the object.)

cacheBucket.Insert("test_key", "fwefgewfwefwefewfew");
return cacheBucket.Get<string>("test_key");

There are multiple buckets on the Couchbase server, each behind it’s own port. Does that matter at all? It still seems odd that I wouldn’t need to specify a username and password in order to insert/get cache objects, like I have to do with the Cluster.CreateManager function.

Thank you for your suggestion though! Any other ideas?

@ajtatum -

What version of the client are you using? The latest is 2.1.0 you should upgrade to the latest.

Is there an exception included with the result? If so post it and the stacktrace. Also, if you enable logging (http://docs.couchbase.com/developer/dotnet-2.1/setting-up-logging.html) what do you see?

-Jeff