c# - AppFabric 1.0错误服务器集合不能为空

标签 c# asp.net appfabric windows-server appfabric-cache

当我运行简单的 Windows Server App Fabric 1.0 演示控制台应用程序时,出现以下错误:

ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty.

请帮助我..我错过了什么..??我查遍了互联网上的所有地方,似乎没有什么可以解决这个问题。谢谢..

我的申请如下:

static void Main(string[] args)
{
    var factory = new Microsoft.ApplicationServer.Caching.DataCacheFactory(); <--- *** Error here

    var cache = factory.GetDefaultCache();
    var key = "mykey";
    var obj = cache[key];
    if (obj == null)
    {
        cache[key] = "I am data for caching";
    }
    obj = cache[key];
    Console.WriteLine(obj);
    Console.Read();
}

我的app.config如下:

<?xml version="1.0"?>
<configuration>
<configSections>
    <section name="dataCacheClients"
                type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" /> 
</configSections>
<dataCacheClients>
<dataCacheClient>
    <hosts>
        <host name="MyMachineNameHere" cachePort="22233" />
    </hosts>
</dataCacheClient>
</dataCacheClients>
</configuration>

最佳答案

我按如下方式更新了我的应用程序配置并且它有效......

<?xml version="1.0"?>
<configuration>

    <!--configSections must be the FIRST element -->
    <configSections>
        <!-- required to read the <dataCacheClient> element -->
        <section name="dataCacheClient"
            type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
            Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, 
            Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            allowLocation="true"
            allowDefinition="Everywhere"/>
    </configSections>

    <!-- cache client -->
    <dataCacheClient>
        <!-- cache host(s) -->
        <hosts>
            <host
               name="MyMachineNameHere"
               cachePort="22233"/>
        </hosts>
    </dataCacheClient>


</configuration>

关于c# - AppFabric 1.0错误服务器集合不能为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13279038/

相关文章:

c# - 在 MVC Controller 中加载 XML

asp.net - 依赖注入(inject)到 AuthorizationFilterAttribute

azure - 我可以从开发模拟器访问 Azure AppFabric 缓存吗?

c# - 尝试从 ListBox 键值对读取 "Value"时出现无效的转换错误

c# - 类级别的 XUnit 理论类数据,而非方法

c# outputcache 在 php 中等效?

c# - 具有 IsIDenity 和 cmd.Parameters.Add 的存储过程

css - 母版页不抓取 contentPlaceHolder 的样式

powershell - 移动和重命名AppFabric配置数据库

.net - AppFabric - Etw - 无法注销跟踪提供程序