Hello,
i tried running the example Couchbase.NetDP1 in C#.
I changed the code so i connect to my server and bucket:
private void button1_Click(object sender, EventArgs e)
{
Cluster cluster = InitializeCluster2();
var bucket = GetBucket(cluster, “NewUserLink”);
}
private Cluster InitializeCluster2()
{
//Create a custom configuration specifiy a max pool size of 10
ClientConfiguration configuration = new ClientConfiguration();
configuration.PoolConfiguration.MaxSize=10;
configuration.PoolConfiguration.MinSize=10;
configuration.Servers.Clear();
configuration.Servers.Add(new Uri("http://192.118.63.84:8091/pools"));
BucketConfiguration bc = new BucketConfiguration();
bc.Password = "mypass";
bc.Username = "admin";
bc.BucketName = "NewUserLink";
bc.Servers.Clear();
bc.Servers.Add("192.118.63.84");
bc.Port = 11211;
configuration.BucketConfigs.Clear();
configuration.BucketConfigs.Add("NewUserLink", bc);
//Initialize the cluster using the default configuration
Cluster.Initialize(configuration);
//Get an instance of the cluster;
return Cluster.Get();
}
private IBucket GetBucket(Cluster cluster, string bucketName)
{
//Open the default bucket
return cluster.OpenBucket(bucketName);
}
when i run it i get message: when i use the default port and bot set the bc.port i get message: “Invalid URI: Invalid port specified.” when i set the port to my bucket port 11211 i get the message: “Object reference not set to an instance of an object” in line “cluster.OpenBucket” .
any idea?
thanks,
ruby