How to: Prepare the Development Environment (Velocity)

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This topic describes how to prepare your Visual Studio project so that you can start developing cache-enabled applications. To program with Microsoft project code named "Velocity," the Microsoft.Data.Caching assemblies must be made available to your Visual Studio project. For more information, see Installing Cache Client Assemblies (Velocity).

The following procedures assume that you have already performed the "Velocity" installation on one or more cache servers, or on your development workstation. For more information about installation, see Installation and Deployment (Velocity).

In addition to installing "Velocity," you must start the cache cluster with the Start-CacheCluster command and create a named cache with the New-Cache command. For more information, see Cache Administration with PowerShell (Velocity).

Preparing Your Project for "Velocity"

The assemblies required for developing cache-enabled applications are located in the "Velocity" installation folder. To develop applications that use these assemblies, the following three steps must be performed to prepare your development environment:

  1. Copy the assemblies to your development workstation.

  2. Set references to the assemblies in your Visual Studio project.

  3. Configure the cache client by using an XML-based application configuration file, or programmatically with code.

To copy assemblies

  1. Copy the assemblies to the development workstation from the installation folder of the cache server. This location was selected during installation of the "Velocity" cache host service.

  2. Copy the following assemblies from the cache server to the same folder on the development workstation: CacheBaseLibrary.dll, ClientLibrary.dll, FabricCommon.dll, and CASBase.dll.


It is important that your application or development environment uses the same assemblies as the cache servers. During any upgrade of the distributed cache system, make sure that all cache clients using that system have the same versions of assemblies. Check this by comparing the Product version of the cache client's ClientLibrary.dll file with the Product version of the cache server's ServiceLibrary.dll file that is located in the installation folder.

Once the assemblies have been copied to the same folder in your development workstation, set references to them by following these steps.

To set references

  1. After creating a new project in Visual Studio, from the Solution Explorer, right-click References and then select Add Reference.

  2. Select the Browse tab, and then locate the copies of the assemblies from step 1 and select CacheBaseLibrary.dll and ClientLibrary.dll. To select more than one file, hold down Ctrl as you select them with the mouse. When all the files have been selected, click OK. This adds Microsoft.Data.Caching assemblies to the reference list for your application.

  3. (optional) Add the using statement (Imports in Visual Basic) at the top of the code file to reference the Microsoft.Data.Caching namespace. This prevents having to add the "Microsoft.Data.Caching" prefix to each "Velocity" class when you program cache operations.

In order for the "Velocity" assemblies to communicate with the cache cluster, the cache client must be configured to run as either a simple client or a routing client.

To configure the cache client

  1. Decide whether you want a routing or simple client. For best performance, use a routing client if your application (and development workstation) will have network connectivity to all cache hosts in the cluster. For more about the cache client types, see Cache Clients and Local Cache (Velocity).

  2. Configure your cache client by using an application configuration file or programmatically. For examples about how to do this, see How to: Get Started with a Routing Client (XML) (Velocity) and How to: Get Started with a Routing Client (Code) (Velocity).


The following is an example of a routing client configured by using an application configuration file. This example has local cache disabled and two cache hosts listed: CacheServer1 and CacheServer2. For more information, see How to: Get Started with a Routing Client (XML) (Velocity).


Data in the cache is not encrypted and is available to any cache client with the appropriate configuration settings. We highly recommend that you secure the XML-based application configuration files, if used, to specify the cache client.

<?xml version="1.0" encoding="utf-8" ?>
  <!--configSections must be the FIRST element -->
    <!-- required to read the <dataCacheClient> element -->
    <section name="dataCacheClient"
    <!-- required to read the <fabric> element, when present -->
    <section name="fabric"
  <!-- routing client-->
  <dataCacheClient deployment="routing">

    <!-- (optional) specify local cache 
      ttlValue="300" />

    <!--(optional) specify cache notifications poll interval 
    <clientNotification pollInterval="300" />
    <!-- cache host(s) -->    

The following is an example of how to configure a routing client programmatically. This example has local cache disabled, only lists one cache server (CacheServer2), and creates a cache client for a cache called NamedCache1. For more information, see How to: Get Started with a Routing Client (Code) (Velocity).

'declare array for cache host(s)
Dim servers(0) As DataCacheServerEndpoint

'specify cache host(s)
servers(0) = New DataCacheServerEndpoint("CacheServer2", _
                            22233, "DistributedCacheService")

'specify cache client configuration
Dim mycacheFactory As DataCacheFactory _
    = New DataCacheFactory(servers, True, False)

'get cache client for cache "NamedCache1"
Dim myDefaultCache As DataCache
myDefaultCache = mycacheFactory.GetCache("NamedCache1")
//declare array for cache host(s)
DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];

//specify cache host(s)
servers[0] = new DataCacheServerEndpoint("CacheServer2", 
                        22233, "DistributedCacheService");

//specify cache client configuration
DataCacheFactory mycacheFactory 
    = new DataCacheFactory(servers, true, false);

//get cache client for cache "NamedCache1"
DataCache myDefaultCache = mycacheFactory.GetCache("NamedCache1");

See Also


Application Configuration Settings (Velocity)
Client Configuration Options (Velocity)
XML-Based Client Configuration (Velocity)
Programmatic Client Configuration (Velocity)

Other Resources

Configuring the Cache Client with XML (Velocity)
Using Basic Cache Methods (Velocity)
Installation and Deployment (Velocity)
Using Basic Cache Methods (Velocity)
Using Configuration Methods (Velocity)
Cache Concepts (Velocity)
Administration Guide (Velocity)