Exception when try to get a bucket


I m facing with an exception when I try to open the bucket. This is an ASP project.

The code is realy simple

   private static bool IsInitialized;
   private static string BucketName;

   private static void Initialize()
       if (IsInitialized)

       // Build the configuration for the bucket
       var configuration = new ClientConfiguration();
       //Clear default values

       //Bucket config
       BucketName = RoleEnvironment.GetConfigurationSettingValue("CouchbaseBucket");
       var bucketConfig = new BucketConfiguration
           BucketName = BucketName,
            Password = RoleEnvironment.GetConfigurationSettingValue("CouchbaseBucketPassword"),
            UseSsl = false,
            PoolConfiguration = new PoolConfiguration {
                MinSize = 1,
                MaxSize = 20

       //Add servers from config
       var servers = RoleEnvironment.GetConfigurationSettingValue("CouchbaseServers").Split(',');
       foreach (var server in servers)
           var uri = new System.Uri("http://" + server + ":8091/pools");

       IsInitialized = true;

   public static IBucket GetBucket()
       if (!CouchbaseManager.IsInitialized)

       return ClusterHelper.GetBucket(BucketName);  

The error occurs at line

return ClusterHelper.GetBucket(BucketName);  

The exception details are

System.AggregateException was unhandled by user code
Message=Could not bootstrap - check inner exceptions for details.
in Couchbase.Core.ClusterController.CreateBucket(String bucketName, String password)
in CouchBaseRepository`1.OpenBucket() in CouchBaseRepository.cs:ligne 32

in SyncInvokeAcceptIpTracking(Object , Object[] , Object[] )
in System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
in System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
InnerException: System.AggregateException
Message=One or many errors occurs
in Couchbase.Configuration.Server.Providers.CarrierPublication.CarrierPublicationProvider.GetConfig(String bucketName, String password)
in Couchbase.Core.ClusterController.CreateBucket(String bucketName, String password)
InnerException: System.NullReferenceException
Message=Object reference not set to an instance of an object
in Couchbase.Configuration.Server.Providers.CarrierPublication.CarrierPublicationProvider.GetConfig(String bucketName, String password)

Someone has an idea why I get this error ?


I cut and pasted this code into console app, replacing the calls to RoleEnvironment.GetConfigurationSettingValue with hardcoded values and it worked. You might want make sure that the correct values are being stored in the configuration file. Is there more to the stacktrace?

You can also create a Jira ticket and attach an example project and I take a look at it.


In fact the code was working well and stop to work without a reason on production.

The app is hosted in Azure. And we are almost sure the production stop to work after an instance update.
In Azure, hosts are auto updated.

Also I think you need to test on an ASP project.

I wll try to create a simple project with the same issue.


I open the ticket https://issues.couchbase.com/browse/NCBC-818

That is important information! So, the app was runnning in Aure and there was an instance update? Would it be possible to post the logs around the time it failed to the ticket?

No sorry I don’t have the log.

I reproduce the bug outside of Azure.


Ok, thanks!

Please be aware that when using a configuration file, the file can depend on your build configuration.

This will typically mean that switching between “Debug” and “Release” build will point to different config files.

Therefore, please check the value returned when calling:

Hope this helps