Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-1048

.NET Hello world example does not work

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 2.2.2
    • 2.2.4
    • docs
    • None
    • VS 2013
      Windows 7

    Description

      Marking at this as blocker because it is extremely frustrating that a new user cannot simple copy, paste and run the hello world example.

      using Couchbase.Core;
      using Couchbase.Core.Buckets;
       
      internal class Program
      {
          private static readonly Cluster Cluster = new Cluster();
       
          private static void Main(string[] args)
          {
              using (var bucket = Cluster.OpenBucket())
              {
                  var document = new Document<dynamic>
                  {
                      Id = "Hello",
                      Content = new
                      {
                          name = "Couchbase"
                      }
                  };
       
                  var upsert = bucket.Upsert(document);
                  if (upsert.Success)
                  {
                      var get = bucket.GetDocument<dynamic>(document.Id);
                      document = get.Document;
                      var msg = string.Format("{0} {1}!", document.Id, document.Content.name);
                      Console.WriteLine(msg);
                  }
                  Console.Read();
              }
          }
      }
      

      Error message when you try and build:

      Error	1	The type or namespace name 'Cluster' could not be found (are you missing a using directive or an assembly reference?)	c:\users\dave\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs	12	29	ConsoleApplication1
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          Missing the following line:

          using Couchbase;
          

          Here is the whole code:

          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          using System.Threading.Tasks;
          using Couchbase.Core;
          using Couchbase.Core.Buckets;
          using Couchbase;
           
           
          internal class Program
          {
              private static readonly Cluster Cluster = new Cluster();
           
              private static void Main(string[] args)
              {
                  using (var bucket = Cluster.OpenBucket())
                  {
                      var document = new Document<dynamic>
                      {
                          Id = "Hello",
                          Content = new
                          {
                              name = "Couchbase"
                          }
                      };
           
                      var upsert = bucket.Upsert(document);
                      if (upsert.Success)
                      {
                          var get = bucket.GetDocument<dynamic>(document.Id);
                          document = get.Document;
                          var msg = string.Format("{0} {1}!", document.Id, document.Content.name);
                          Console.WriteLine(msg);
                      }
                      Console.Read();
                  }
              }
          }
          

          pvarley Patrick Varley added a comment - Missing the following line: using Couchbase; Here is the whole code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Couchbase.Core; using Couchbase.Core.Buckets; using Couchbase;     internal class Program { private static readonly Cluster Cluster = new Cluster();   private static void Main(string[] args) { using (var bucket = Cluster.OpenBucket()) { var document = new Document<dynamic> { Id = "Hello", Content = new { name = "Couchbase" } };   var upsert = bucket.Upsert(document); if (upsert.Success) { var get = bucket.GetDocument<dynamic>(document.Id); document = get.Document; var msg = string.Format("{0} {1}!", document.Id, document.Content.name); Console.WriteLine(msg); } Console.Read(); } } }
          jmorris Jeff Morris added a comment -

          Marija -

          I am assigning to you to see if you can update the docs with the example Patrick Varley provided above. if you prefer i can update it myself and push a pull request.

          Let me know if you have any questions. pr want to discuss.

          -Jeff

          jmorris Jeff Morris added a comment - Marija - I am assigning to you to see if you can update the docs with the example Patrick Varley provided above. if you prefer i can update it myself and push a pull request. Let me know if you have any questions. pr want to discuss. -Jeff

          code replaced as requested both for CB 4.1 and C B 4.0

          marija Marija Jovanovic (Inactive) added a comment - code replaced as requested both for CB 4.1 and C B 4.0

          People

            marija Marija Jovanovic (Inactive)
            pvarley Patrick Varley
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty