Search code examples
c#asp.netappfabricwindows-server

datacacheexception Cache referred to does not exist


I get the following error when I invoke the call factory.GetDefaultCache()...

ErrorCode:SubStatus:Cache referred to does not exist. Contact administrator or use the Cache administration tool to create a Cache.

Please help.. thanks..

Here is my simple application:

var config = new Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration();
var servers = new List<Microsoft.ApplicationServer.Caching.DataCacheServerEndpoint>();
servers.Add(new Microsoft.ApplicationServer.Caching.DataCacheServerEndpoint("mymachine123", 22233));
config.Servers = servers;
var factory = new Microsoft.ApplicationServer.Caching.DataCacheFactory(config);

////var factory = _cacheFactory;

var cache = factory.GetDefaultCache();  <---- *** Error happens here..***
var key = "mykey";
var obj = cache[key];
if (obj == null)
{
    cache[key] = "I am data for caching";
}
obj = cache[key];
Console.WriteLine(obj);

When I run the command: start-cachecluster, I get the following:

HostName : CachePort Service Name Service Status Version Info -------------------- ------------ -------------- ------------ mymachine123:22233 AppFabricCachingService UP 1 [1,1][1,1]


Solution

  • Having just set this up myself.. it may be a permissions issue. Add the user that the caching service is running under via Grant-CacheAllowedClientAccount <youraccountname>