Getting started
This section shows how to add the Couchbase .NET SDK to your application and how to get up and running with the client by way of a simple “Hello Couchbase” application.
Installing the Client
You can add the Couchbase .NET SDK to your code by using one of the following methods:
- Using NuGet (recommended method)
- Downloading and referencing the binaries
- Building from source yourself
The following sections explain in detail how to get started using each method.
Using NuGet
For every release, we package the binaries and store the latest version in NuGet. If you are not familiar with NuGet, it’s the official and most widely supported package manager for Microsoft Visual Studio and .NET in general. NuGet.org is a centralized repository for package authors and consumers, and it also defines a suite of tools for authoring and consuming packages.
Using Visual Studio 2012 or later, follow these steps to get started with the Couchbase .NET SDK:
- From the IDE, right-click the project you want to add the dependency to.
- In the context menu, click Manage NuGet Packages. The NuGet package manager modal dialog opens.
- From the Tree View menu on the left, select Online and then nuget.org.
- In the search box at the top right-hand side of the dialog, type CouchbaseNetClient and then press enter on your keyboard.
- In the search results, select the CouchbaseNetClient package and then click Install.
That’s it! NuGet will pull in all required dependencies and reference them. You're ready to start coding!
As an alternative to using the Visual Studio IDE, you can include the binaries by using the Package Manager Console. The main advantage of using the Package Manager Console is that the NuGet Dialog by default always installs the latest version of the package published to NuGet.org, however the console allows you to define the version of the package you want to include. For users targeting older builds of the SDK, using the Package Manager Console is the best option.
To use the Package Manager Console to include the SDK in your project:
- From the Visual Studio menu bar, click Tools.
- Select .
- In the console, enter the package installation command:
- To install the latest version:
Install-Package CouchbaseNetClient
- To install a specific version, include the version parameter. For
example:
Install-Package CouchbaseNetClient -Version 2.0.0-beta -Pre
- To install the latest version:
Downloading and referencing the binaries
If you do not want to use NuGet to include the Couchbase .NET SDK in your project, you can download and reference the binaries directly. If you chose this route, you’ll also be responsible for including and resolving dependencies used internally by the SDK.
To download and reference the binaries directly:
- Download the version of the SDK you want to install. The binaries are stored in S3 and the links are available here.
- In Visual Studio, right-click the project you want to include the SDK in and then click Add.
- Click Reference to open the Reference Manager.
- On the left side, click Browse and select the binaries you downloaded.
- Click OK.
After you have referenced the Couchbase .NET SDK binaries, you need to locate and reference the dependencies it uses in a similar fashion. At the time of this writing, the dependencies are:
- Apache Common Infrastructure Libraries for .NET v2.0.0: http://netcommon.sourceforge.net/downloads.html
- Json.NET v6.0.1: https://json.codeplex.com/releases/view/126052
Other versions might not be compatible with the current SDK version.
Building from source
If none of the other installation options suffice or if you want to debug the source or perhaps contribute, building directly from the source is the best option for you. All source is located on Github.
The software provided via NuGet and S3 are the official releases that have been through a rigorous testing process. Code on GitHub that is not tagged as an official release should be considered “in development”.
To build the .NET SDK from source:
- (Optional) Fork the GitHub repository: https://github.com/couchbase/couchbase-net-client/fork
- Using a Git console, enter the command to clone the repository:
git clone https://github.com/couchbase/couchbase-net-client.git
- Enter the command to retrieve the latest code from GitHub:
git pull origin master
- Navigate to the directory that the source was cloned to and open the solution.
- Build the solution.
After you have successfully built the source, it’s then just a matter of referencing the binaries (.DLL files) from your consuming project.