C# 引用的datacacheexception缓存不存在

C# 引用的datacacheexception缓存不存在,c#,asp.net,appfabric,windows-server,C#,Asp.net,Appfabric,Windows Server,调用调用工厂时出现以下错误。GetDefaultCache() 错误代码:子状态:引用的缓存不存在。请与管理员联系或使用缓存管理工具创建缓存。 请帮忙。。谢谢 以下是我的简单应用程序: var config = new Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration(); var servers = new List<Microsoft.ApplicationServer.Caching.DataCache

调用调用工厂时出现以下错误。GetDefaultCache()

错误代码:子状态:引用的缓存不存在。请与管理员联系或使用缓存管理工具创建缓存。

请帮忙。。谢谢

以下是我的简单应用程序:

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);
var config=new Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration();
var servers=新列表();
添加(新的Microsoft.ApplicationServer.Caching.DataCacheServerEndpoint(“mymachine123”,22233));
config.Servers=服务器;
var factory=新的Microsoft.ApplicationServer.Caching.DataCacheFactory(配置);
////变量工厂=_cacheFactory;

var cache=factory.GetDefaultCache() 我自己刚安排好的。。这可能是权限问题。通过
Grant CacheAllowedClientAccount

添加运行缓存服务的用户。我的代码在第二天工作,没有任何更改。。我没有手动启动缓存服务。。但是使用了start cachecluster命令来启动服务。。这可能会有所不同,但无论如何感谢您的回答。如果appfabric服务器由IIS访问,则必须向IIS用户(IIS\u IUSRS)授予权限,如果是生产环境,则可能必须向AppPool/YourApplicationPool\u INIS授予权限